As a small piece of a column script I'm planning to post this week, I thought I'd have a look at formatting dates according to a script-specified format.
JS has some facility to parse date strings that conform to a certain format:
var myDate = new Date(datestring);
datestring has to be in a format parse-able by Date.parse()
I gave that a go with modify and modify_utc. The idea is to do something like:
myDateFormat = "yymmdd";
(...)
var myDate = new Date(ColumnData.item.modify);
ColumnData.value = myDate.format(myDateFormat);
That won't work with the strings offered by modify and modify_utc.
I'm sure the question of converting a column date to a JS Date has come up before.
What would be the best way to do it?
modify and modify_utc are not strings, they are VT_DATE variants. (If you use them in a context that requires strings, Javascript might turn them into strings, but they aren't strings coming out of Opus.)
var javaScriptDate = new Date(item.modify); should work.