Created
October 6, 2016 01:35
-
-
Save alexdiliberto/f7a7b1a7b222119c413d3a2ea8311efa to your computer and use it in GitHub Desktop.
Vanilla JS date and number formatting
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
// "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