Joined October 2022
·

Jonathan Hudson

This is wrong. getTimezoneoffset() returns the offset in minutes. This would basically turn your minutes into hours and then subtract that from milliseconds which would not do anything correct. Use this instead:

const toLocalTime = (time) =>{ 
    let d = new Date(time); 
    let offset = (new Date().getTimezoneOffset() * 6000); 
    return new Date(d.getTime() + offset);
};
Achievements
1 Karma
0 Total ProTip Views