I try to run this js
return function(milliSeconds, timeZoneId) {
if (milliSeconds == 0) {
return \"\";
}
var now = moment();
return now.
I'm working on similar topic and got answer to your original question. Hope will help other people if this is too late to you.
First of all, just like @VincenzoC explained: 1. Have to change the Unix timestamp to 10-digit for Moment.JS. 2. The format for year should be "YYYY" instead of "yyyy".
Per the explanation here enter link description here POSIX compatibility requires that the offsets are inverted. Therefore, Etc/GMT-X will have an offset of +X and Etc/GMT+X will have an offset of -X. This is a result of IANA's Time Zone Database and not an arbitrary choice by Moment.js.
You need to change set as: var timezoneId = "Etc/GMT+08"; Then run moment.unix(1524578400).tz("Etc/GMT+8").format('MMM d, YYYY H:mm:ss Z');
The return is: "Apr 2, 2018 6:00:00 -08:00" Please note what you expect is 5am but it's Day light saving time, so the return is 6am which is correct.