Skip to content

Instantly share code, notes, and snippets.

@Dodotree
Created July 11, 2021 05:17
Show Gist options
  • Select an option

  • Save Dodotree/6bff8c0126ac69d57059e614c8941fb3 to your computer and use it in GitHub Desktop.

Select an option

Save Dodotree/6bff8c0126ac69d57059e614c8941fb3 to your computer and use it in GitHub Desktop.
Js small time lapse printing and detection of saving time on top of time zone difference
//Example: timeLapseToString(new Date()-t0);
function timeLapseToString(lapse_int) {
let lapse = new Date(lapse_int);
return `${lapse.getUTCHours()}:${lapse.getUTCMinutes()}:${lapse.getUTCSeconds()}`;
}
function getSavingTimeMin() {
let mins = (new Date("Thu, 01 Jan 1970 00:00:00") - new Date("Thu, 01 Jan 1970 00:00:00 GMT"))/(60*1000);
let ofs = new Date().getTimezoneOffset();
return mins - ofs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment