momentjs Getting started with momentjs Installation or Setup


Example

Moment is a javascript library that was designed to make working with dates and times less time-consuming and more intuitive.
You can easily start using this library by installing it in you web-app by using one of the following guides.

Browser

You can either download the JS file from the official website or use cdnjs.com.

With local JS file

<script src="moment.js"></script>
<script>
    moment().format();
</script>

With CDN

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script>
<script>
    moment().format();
</script>

Node.js

npm install moment

Moment should be included inside the node_modules directory, Then add it to your script

var moment = require('moment');
moment().format();

Bower

bower install --save moment

To test if you site or web application is properly using the moment.js script, open console (F12 on the keyboard) and type moment, the console should print the moment function if it was included.