Skip to content

Instantly share code, notes, and snippets.

@luizcarraro
Created May 2, 2018 13:50
Show Gist options
  • Save luizcarraro/302606187492a74d2f8f0df0086cf09d to your computer and use it in GitHub Desktop.
Save luizcarraro/302606187492a74d2f8f0df0086cf09d to your computer and use it in GitHub Desktop.
localISOTime - Ignorar o timezone e pegar a data local em ISO String
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