I am trying to pass the user’s local time to my backend. Any calls to instances of Date()
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) seem to lose the timezone information, inhibiting me from determining the user’s local time.
console.log('Local Time:', new Date().toString());
console.log('Local Time:', new Date());
Outputs:
Local Time: Wed Jan 08 2025 03:48:49 GMT (Coordinated Universal Time)
Local Time: Tue Jan 07 2025 22:48:49 GMT-0500 (Eastern Standard Time)
I am finding the same issue with other instance methods of Date()
.