Using Moment timezone library we can convert from UTC or any timezone to desired timezone. Moment timezone library supercedes the moment library where we can use the functions defined within the moment library
npm i moment-timezone
var moment = require('moment-timezone')
let originDate = moment(new Date()).utc().format("YYYY-MM-DD HH:mm:ss").toString()
let m = moment.utc(originDate);
m.tz('America/Chicago');
let convertedDate = m.format("YYYY-MM-DD HH:mm:ss");
We can also convert from a specific timezone instead of UTC
let fromTimezone = moment.tz("2023-10-08T10:00:00", "America/Los_Angeles")
let toTimezone = fromTimezone.tz("America/Los_Angeles").format("YYYY-MM-DD HH:mm:ss")
Thanks, it worked
Wow, this article is good, my sister is analyzing such things, thus I am going to let know her.
I am sure this post has touched all the internet visitors, its really really good article on building up new webpage.