Created
July 11, 2021 05:17
-
-
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
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
| //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