I have a dateTime object that I'm using to reflect the status of an item. Below is the code I have for the object:
let status = new Date(Date.parse(dateTime)).toLocaleString('en-US', {year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute:'2-digit'}))
Currently status returns, regardless of timezone: 10/19/2022, 10:13 PM
I am in US Central Time. When I console.log
new Date(Date.parse(dateTime))
I get Wed Oct 19 2022 22:13:00 GMT-0500 (Central Daylight Time)
.
However when I change my computer's time to US Eastern Time, I get:
Wed Oct 19 2022 22:13:00 GMT-0400 (Eastern Daylight Time)
.
This is not correct. I'm expecting Eastern Time to show 11:13 PM or 23:13:00. How should I modify the code to reflect the actual local browser time?