I need to convert German local time records, without zone info, i.e.,
var data = [
"2017-12-02 20:27:02",
"2017-12-02 20:50:00"
]
to UTC records, i.e., subtract the time zone offset and respect the daylight saving. I know that there are the getTimezoneOffset
and toISOString
functions, which would work if my system locale is set German. For instance I could convert the dates using
var d = new Date(data[0])
> Sat Dec 02 2017 20:27:02 GMT+0100 (CET)
d.toISOString()
> '2017-12-02T19:27:02.000Z'
However I need a safe solution that works on any server with any locale, e.g., in the cloud.