See our collection of 5 of the most imponent time and dates libraries written in Javascript.

Top 5: Best open source time and dates formatting related Javascript libraries

You may want to show a human readable date to your users, nobody wants to spend some seconds thinking if from a given date, the first number is a day or is the month (i.e 09.09.2016) or think which day of the week it was, that's pretty boring and annoying.

However, we know for example that a search engine crawler prefers complicated formats (that we as humans we don't want to read), so probably you may want to let the complicated format at charge of your server language and then make it easy in the view with Javascript. Create readable time information formatting it with javascript libraries to improve your user experience.

Is up to you which library suits better to your needs, choose between robust, simple or compact libraries to format a date in Javascript. Enjoy our collection from 5 of the most imponent libraries to format time and dates with Javascript.

5. Date format

Homepage | Github

A JavaScript date format library that uses the same method as PHP's date() function. This was developed to allow for the formatting of dates in JavaScript and ActionScript like PHP can do.

Using it is simple, but you may need to refer to the available format string options often to remember how to use it. I always need to refer to PHP’s date documentation every time I use it. You may also escape letters to make them literal, but be sure to escape your escape so Javascript can handle the string correctly.

4. XDate

Homepage

XDate

XDate is a thin wrapper around JavaScript's native Date object that provides enhanced functionality for parsing, formatting, and manipulating dates. It implements the same methods as the native Date, so it should seem very familiar. Also, it is non-destructive to the DOM, so it can safely be included in third party libraries without fear of side effects.

3. DateJS

Homepage | Github

Datejs

Datejs is an open-source JavaScript Date Library. Comprehensive, yet simple, stealthy and fast. Datejs has passed all trials and is ready to strike. Datejs doesn’t just parse strings, it slices them cleanly in two.

Datejs has support for localization to display your dates in different languages.

2. jQuery timeago

HomepageGithub

jQuery timeago

Timeago is a jQuery plugin that makes it easy to support automatically updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago") from ISO 8601 formatted dates and times embedded in your HTML.

All the elements in which timeago was used, will be automatically refreshed.

1. Moment.js

Homepage | Github

Moment.js

Moment.js is a Javascript library that allow you to parse, validate, manipulate, and display dates in JavaScript in an easy and comfortable way. Moment was designed to work both in the browser and in Node.js. All code should work in both of these environments, and all unit tests are run in both of these environments.

Besides, Moment.js has support for localization (using locale packages) to display dates in different languages.

Currently the following browsers are used for the ci system: Chrome on Windows XP, IE 8, 9, and 10 on Windows 7, IE 11 on Windows 10, latest Firefox on Linux, and latest Safari on OSX 10.8 and 10.11.

If you know another awesome and compact library to format dates and time in Javascript, please share it with the community in the comment box.


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors