Reputation: 15928
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.
Upvotes: 0
Views: 1053
Reputation: 25840
Please try
moment.tz("2016-06-21 16:00:00", "America/New_York").utc().format();
It gives desired output
Upvotes: 3