Last active
January 19, 2022 23:52
-
-
Save patricksimpson/f0108b43c26ea85ee6d8c5f281ab011e to your computer and use it in GitHub Desktop.
date string to local
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dateToLocal(date) { | |
let localOffset = new Date().getTimezoneOffset() * 60 * 1000; | |
let d = new Date(Date.parse(date)); | |
return new Date(d.getTime() + localOffset); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment