简体   繁体   中英

How to convert Local Date Time to UTC and UTC to specific TimeZone using javascript?

1) var sd = new Date("2018-02-20T00:00:00");

I want to convert this local date to UTC DateTime.

2) How to convert "2018-02-20T08:00:00Z" this UTC date to "India Standard Time" or any timezone standard.

var isoDate = new Date('2018-02-22').toISOString();

This might Work:

var sd = new Date("2018-02-20T00:00:00");

var utc = new Date(sd.getUTCFullYear(), sd.getUTCMonth(), sd.getUTCDate(),  sd.getUTCHours(), sd.getUTCMinutes(), sd.getUTCSeconds());

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM