I try to run this js
return function(milliSeconds, timeZoneId) {
if (milliSeconds == 0) {
return \"\";
}
var now = moment();
return now.
As moment.tz(..., String) docs states:
The moment.tz constructor takes all the same arguments as the
momentconstructor, but uses the last argument as a time zone identifier.
A time zone identifier is something like 'America/New_York' or 'Europe/Rome', "GMT-08:00" is not a valid input.
In your case you can use moment(Number) and then:
var milliSeconds = "1524578400000";
var timezoneId = "GMT-08:00";
var timeInt = parseInt(milliSeconds, 10)
var m1 = moment(timeInt).tz('America/Los_Angeles');
console.log(m1.format('MMM D, YYYY H:mm:ss'));
var offset = timezoneId.substring(3);
var m2 = moment(timeInt).utcOffset(offset);
console.log(m2.format('MMM D, YYYY H:mm:ss'));
Please note that:
YYYY for years and D for day of the month (d is day of the week)1524578400000 is 2018-04-24 14:00:00 UTC, I'm missing why you are expecting 5am as output.