FormatJS: Localize dates and numbers

Home » Blog » Software » FormatJS: Localize dates and numbers

Internationalization and localization still is a somewhat difficult problem in software development. FormatJS is a collection of JavaScript libraries that addresses a part of this problem by formatting dates and numbers according to a selected locale.

It makes clever use of pluralization and natural language patterns so the output strings read like a natural language utterance instead of a computer-generated string, for example it generates these outputs for 0, 1 and 1,000 items, respectively:

“Annie took no photos on December 14, 2014.”
“Annie took one photo on December 14, 2014.”
“Annie took 1,000 photos on December 14, 2014.”

FormatJS applies similar logic to date representations. Today (21-12-2014) the abstract date “2014-11-21” for instance is represented as “last month”, “1 month ago” or “31 days ago”.

FormatJS works both in the browser and in JavaScript server environments such as node.js. While not a catch-all solution for all your i18n woes it’s a very useful library for elegantly solving a specific problem in this space.

Leave a Comment

* Checkbox GDPR is required


I agree

By continuing to browse the site you agree to our use of cookies. Privacy Policy

Privacy Preference Center

Strictly necessary

These cookies are necessary for the site to function.

PHPSESSID: Preserves user session state across page requests.

__cfduid: Used by the content network, Cloudflare, to identify trusted web traffic.



Remembers the user's submitted data when a comment is submitted in a blog post. The purpose is to aut o-populate form fields for subsequent comments, in order to save time for the user.



Statistic cookies help us to understand how visitors interact with our websites by collecting and reporting information anonymously.

_ga: Registers a unique ID that is used to generate statistical data on how the visitor uses the website.

_gat: Used by Google Analytics to throttle request rate.

_gid: Registers a unique ID that is used to generate statistical data on how the visitor uses the website.

collect: Used to send data to Google Analytics about the visitor's device and behaviour. Tracks the visitor across d evices and marketing channels.



We use Wordfence to secure our website against hacking attempts:


Close your account?

Your account will be closed and all data will be permanently deleted and cannot be recovered. Are you sure?