I want to write a method in javascript that takes a date and time zone and then returns a new date thats in UTC.
For example if I give it
Date: 2016/06/21 16:00:00
Time zone: America/NewYork
I should get back
Date: 2016/06/21 20:00:00
I looked at moment js, but seems like they didn't have a utc timezone name.
Please try
moment.tz("2016-06-21 16:00:00", "America/New_York").utc().format();
It gives desired output
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.