Created
May 2, 2018 13:50
-
-
Save luizcarraro/302606187492a74d2f8f0df0086cf09d to your computer and use it in GitHub Desktop.
localISOTime - Ignorar o timezone e pegar a data local em ISO String
This file contains hidden or 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
let tzoffset = (new Date()).getTimezoneOffset() * 60000; //offset em millisegundos | |
let localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1); | |
console.log(new Date()); // 2018-05-02T13:43:10.872Z | |
console.log(localISOTime); // 2018-05-02T10:39:53.953 | |
// Utils para ember (/app/utils/localISOTime.js) | |
export default function () { | |
return (new Date(Date.now() - ((new Date()).getTimezoneOffset() * 60000))).toISOString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment