Skip to content

Instantly share code, notes, and snippets.

@KyleMit
Created October 23, 2020 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KyleMit/dd459659785831d413894c21d4fc85eb to your computer and use it in GitHub Desktop.
Save KyleMit/dd459659785831d413894c21d4fc85eb to your computer and use it in GitHub Desktop.
Twitter - toLocaleDateString
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