I want to get the local time of the client computer.
I have to convert a specific UTC time to the user's local time.
2/10/2019 12:00:00 AM
-->> I have to convert it to user's time
I want to restore the time to the user's time. Could you please convert the time to the user's time
P粉4587250402023-09-09 18:53:52
You can use getTimezoneOffset
or toLocaleString
or toLocaleDateString
.
const d = new Date('2/10/2019 12:00:00 AM'); const clientDate = d.toLocaleString(); const offset = d.getTimezoneOffset(); // offset in minutes console.log({clientDate, offset});