Working: const toLocalTime = (time: Date) => { let d = new Date(time); let offset = (new Date().getTimezoneOffset() * 60000); if (offset < 0) return new Date(d.getTime() - offset); else return new Date(d.getTime() + offset); };
Working:
const toLocalTime = (time: Date) => {
let d = new Date(time);
let offset = (new Date().getTimezoneOffset() * 60000);
if (offset < 0)
return new Date(d.getTime() - offset);
else
return new Date(d.getTime() + offset);
};