Skip to content

Instantly share code, notes, and snippets.

@smks
Created November 12, 2016 19:07
Show Gist options
  • Save smks/7877e466262574b34ddbdf8a0da0d147 to your computer and use it in GitHub Desktop.
Save smks/7877e466262574b34ddbdf8a0da0d147 to your computer and use it in GitHub Desktop.
Features of the Intl API
// Number Formatter
var communityPoints = 35000000.00;
var ukFormatter = new Intl.NumberFormat('en-uk');
var formattedNumber = ukFormatter.format(communityPoints);
console.log(formattedNumber);
// Currency formatter
var houseMaterialCosts = 120457.46;
var currencyFormatter = new Intl.NumberFormat('en-GB', { style: 'currency', currency: 'GBP' });
var formattedCosts = currencyFormatter.format(houseMaterialCosts);
console.log(formattedCosts);
// Date formatter
var dateNow = new Date('September 18, 2020 00:00:00');
var dateFormatter = new Intl.DateTimeFormat("en-uk");
var formattedDate = dateFormatter.format(dateNow);
console.log(formattedDate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment