Easily Display The Date And Time Using Moment.js

How to display the date and time in javascript using the moment.js plugin. Date and time become the main component for a programmer in applying the application. In javascript, manually displaying time is quite troublesome especially when dealing with locale and language of each country. On this occasion, I want to share how to show the time very quickly on javascript.

Read another article: [Resolved] SweetAlert Prompt Not Working On Modal Dialog Bootstrap In Firefox

Moment.js is a library of ichernev works and is designed to be able to parse, validate, manipulate and display dates and times in Javascript. This library works well across browsers or Node.js. For now, browsers used for testing moment.js are IE 8, 9, and 10 in Windows 7, IE 11 on Windows 10, Chrome in Windows XP, latest Firefox on Linux, and the latest Safari on OSX 10.8 and 10.11.

Display The Date And Time Using Moment Javascript Plugin

How to install Moment.js is quite easy, i.e., installed manually by calling the javascript file or installed using the package manager.

Moment.js has two types of libraries:  moment.js  and  moment-with-locales.js . The difference is that moment-with-locales.js supports multiple languages, so you do not have to bother converting dates into the language of your home country.

The moment.js file has a fairly small size of 16.6k (English support only). While moment-with-locales.js has a size of 64.2k and supports 115 languages.

How to use moment.js.

I will display the date and time using Arabic; please copy the following script

Easily Display The Date And Time Using Moment.js

The following example will show the date and time in Indonesian, and please copy the following script

Show Date And Time In Javascript

Similarly, short tutorial Easily Display The Date And Time Using Moment.js, hopefully, useful

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.