In my browser console I'm able to parse dates and get their time in milliseconds:
new Date('2018-10-16 12:41:50.000000');
// => Tue Oct 16 2018 12:41:50 GMT+0200 (Central European Summer Time)
new Date('2018-10-16 12:41:50.000000').getTime();
// => 1539686510000
If I do the same in App scripts, the date is not recognized (defaults to 1970 epoch origin) and getTime()
simply breaks (NaN):
function test_date() {
Logger.log('new Date(date)');
Logger.log(new Date('2018-10-16 12:41:50.000000'));
Logger.log('getTime()');
Logger.log(new Date('2018-10-16 12:41:50.000000').getTime());
}
Am I missing something or are new Date() / getTime()
simply broken in App Scripts?
I'm runnign the above script in a Google Sheet