Last active
October 27, 2017 22:17
-
-
Save hasibomi/b18e0bd46602c294671688e1852677f3 to your computer and use it in GitHub Desktop.
Date time example for javascript
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
const currDateTime = Date.now(); | |
const dateTime = new Date(currDateTime); | |
const months = [ | |
"January", | |
"February", | |
"March", | |
"April", | |
"May", | |
"June", | |
"July", | |
"August", | |
"September", | |
"October", | |
"November", | |
"December" | |
]; | |
document.querySelector("body").append("Timestamp: " + currDateTime); | |
document.querySelector("body").append(", Date: " + dateTime.getDate()); | |
document.querySelector("body").append(", Month: " + dateTime.getMonth()); | |
document.querySelector("body").append(", Month name: " + months[dateTime.getMonth()]); | |
document.querySelector("body").append(", Year: " + dateTime.getFullYear()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment