Last active
July 25, 2020 12:02
-
-
Save lukethacoder/045559b137a2793d0bbe5f4e31ccdc2a to your computer and use it in GitHub Desktop.
JS Dates n Times
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
let now = new Date() | |
let yr = now.getFullYear() | |
let mth = `${ | |
now.getMonth() + 1 < 10 ? `0${now.getMonth() + 1}` : now.getMonth() + 1 | |
}` | |
let dt = `${date.getDate() < 10 ? `0${date.getDate()}` : date.getDate()}` | |
let hrs = `${ | |
date.getHours() < 10 ? `0${date.getHours()}` : date.getHours() | |
}` | |
let mins = `${ | |
date.getMinutes() < 10 ? `0${date.getMinutes()}` : date.getMinutes() | |
}` |
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
const WEEKS_ARRAY = [ | |
'Sunday', | |
'Monday', | |
'Tuesday', | |
'Wednesday', | |
'Thursday', | |
'Friday', | |
'Saturday', | |
] | |
const dayOfWeek = WEEKS_ARRAY[new Date().getDay()]; | |
console.log(`Today is ${dayOfWeek}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment