0

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.

developer747
  • 15,419
  • 26
  • 93
  • 147

1 Answers1

3

Please try

moment.tz("2016-06-21 16:00:00", "America/New_York").utc().format();

It gives desired output

refer this for details

Rohit Shedage
  • 23,944
  • 1
  • 13
  • 18
  • 1
    This is correct, but note to the OP that if you have that date format you will need to specify a format parameter as well as it is not ISO8601 – Maggie Pint Jun 22 '16 at 01:33