Format Date, Number and Currency - Moment.js, Numeral.js and Accounting.js
I came to know libraries which help us in formatting numbers, dates and currency.
1. Moment.js - To parse, validate, and format dates.
Examples:
moment().format('MMMM Do YYYY, h:mm:ss a'); // April 4th 2015, 3:11:47 pm
moment().format('dddd'); // Saturday
moment().format("MMM Do YY"); // Apr 4th 15
// selecting time zone
moment.tz("2015-04-04 11:55", "Indian/Mauritius").format(); // "2015-04-04T11:55:00+04:00"
moment.tz("March 12th 2015 8PM", "MMM Do YYYY hA", "Indian/Mauritius").format();
// "2015-03-12T20:00:00+04:00"
Url: http://momentjs.com/
2. Numeral.js - To format numbers
Examples:
numeral(10000).format('0,0'); // "10,000"
numeral(10000).format('$0,0'); // "$10,000"
numeral(10000).format('0b'); // "10KB"
numeral(0.10).format('0%'); // "10%"
Url: http://numeraljs.com/
3. Accounting.js - To format numbers, money and currency
Examples:
accounting.formatMoney(1000); // "$1,000.00"
// Indian rupee currency formatting
accounting.formatMoney(1000.99, "₹", 2, ".", ","); // "₹1.000,99"
Url: http://openexchangerates.github.io/accounting.js/
Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for.
ReplyDeletewordpress web design