Skip to content

Instantly share code, notes, and snippets.

@alexdiliberto
Created October 6, 2016 01:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexdiliberto/f7a7b1a7b222119c413d3a2ea8311efa to your computer and use it in GitHub Desktop.
Save alexdiliberto/f7a7b1a7b222119c413d3a2ea8311efa to your computer and use it in GitHub Desktop.
Vanilla JS date and number formatting
// "October 5, 2016"
(new Date()).toLocaleString('en-us', {month: 'long', day: 'numeric', year: 'numeric'});
new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' }).format(new Date())
// "$123.45"
Number(123.45).toLocaleString('en-us', { style: 'currency', currency: 'USD' });
new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(123.45);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment