Last post Apr 09, 2020 09:15 AM by Sean Fang
Apr 09, 2020 06:28 AM|rajemessage|LINK
well the question is.
i get datetime in json string "2019-01-01T00:00:000Z"
i do not want to remove Z out of it and i want to show it on page with ddMMyyyy formate, when i use moment(day).format(timeFormat);.
this reduces my date by one as my local is America. so please suggest how should I format.
Apr 09, 2020 09:15 AM|Sean Fang|LINK
I think what you need might be below function.
moment(time).tz(timezone).format(format); //moment-timezone-with-data.min.js contains this function
moment(time).utc().format(format); // moment.min.js contains this function
Let's take "2019-01-01T00:00:00Z" as an example. The result will be different with different timezones.
var time = moment("2019-01-01T00:00:00Z");
var format = 'MMMM Do YYYY hh:mm:ss';
var newYork = time.tz('America/New_York').format(format);
var losAngeles = time.tz('America/Los_Angeles').format(format);
var tokyo = time.tz('Asia/Tokyo').format(format);
var utc = time.utc().format(format);
New York: December 31st 2018 07:00:00
Los Angeles: December 31st 2018 04:00:00
Tokyo: January 1st 2019 09:00:00
UTC: January 1st 2019 12:00:00
Hope this can help you.