Create javascript Date() object to Amrica/New

The code:

console.log(start)

reads, Thu Mar 01 2018 00:00:00 GMT+0530 (India Standard Time)

I want it a new object start_NY which will read Thu Mar 01 2018 00:00:00 wrt America/New_York timezone. Something like Thu Mar 01 2018 00:00:00 GMT-0500 .

I used a script:

start_ny = new Date('Thu Mar 01 2018 00:00:00 GMT-0500');

But that reads, Thu Mar 01 2018 10:30:00 GMT+0530 (India Standard Time) , which is actually converting the date into Indian Standard Time, instead of giving me a time from New_York timezone.

The format should be same as that of the existing one. How can I do that?


尝试使用以下代码和MDN资源

new Date().toLocaleString('en-US', { timeZone: 'America/New_York' })

// Date Format

new Date().toDateString('en-US', { timeZone: 'America/New_York' });
链接地址: http://www.djcxy.com/p/46600.html

上一篇: 如何将日期时间从ISO格式转换为UTC时区?

下一篇: 创建javascript Date()对象到Amrica / New