Created
October 23, 2020 16:03
-
-
Save KyleMit/dd459659785831d413894c21d4fc85eb to your computer and use it in GitHub Desktop.
Twitter - toLocaleDateString
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 dt = new Date(1906, 11, 9) | |
let lang = navigator.language // i.e. 'en-us' | |
// "Sunday, December 9, 1906" | |
dt.toLocaleDateString(lang, { | |
weekday: 'long', | |
year: 'numeric', | |
month: 'long', | |
day: 'numeric' | |
}) | |
// "Dec 9, 1906" | |
dt.toLocaleDateString(lang, { | |
year: 'numeric', | |
month: 'short', | |
day: 'numeric' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment