Last active
December 22, 2020 12:52
-
-
Save erickvasilev/aa87f17e0514630343ce60a10e096cff to your computer and use it in GitHub Desktop.
Date & Time Converter Native - Erick Vasilev
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
Date.prototype.addHours = function(h) { | |
this.setTime(this.getTime() + (h*60*60*1000)); | |
return this; | |
} | |
const singapore_time = new Date().addHours(8); // GMT +8 | |
const date_time = singapore_time.getTime(); | |
const current_timestamp = singapore_time.getTime().toString(); | |
const date_to_utc = ( new Date(date_time)).toUTCString(); | |
const utc_to_epoch = Date.parse(date_to_utc); | |
console.log(date_to_utc) // Tue, 22 Dec 2020 09:38:28 GMT | |
console.log(utc_to_epoch) // 1608629908000 | |
console.log(current_timestamp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment