Skip to content

Latest commit

 

History

History
 
 

Moment

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Moment JS

What is moment JS ?

  • Moment JS is a JavaScript library which helps in parsing , validating , manipulating and displaying date/time in JavaScript in a very easy way.

  • Moment JS allows displaying of date as per localization and in human readable format. You can use Moment JS inside a browser using the script methos . It is also available with Node.js and can be installed using NPM.

Install:

  • We can install moment from MomentJS
  • We can use moment in node JS and in browser as well

Feature of Moment:-

  • You can see all the example of each and every feature in the sample code of moment JS.
  1. Parsing:-Parsing allows you to parse the date int the format required. Parsing of date is available in string . Object and array . There are methods available which gives the date output in UTC format.

  2. Manipulation:- There are various methods to manipulate Date and Time on the moment object. add, subtract, startoftime, endoftime, local, utc, utcoffset etc., are the methods available which gives details required on date/time in Moment JS.

  3. GET/SET:- Get/Set allows to read and set the units in the date. It allows to change as well as read hour , minute, seconds, millisecond, date of month, day of week, day of year, week of year, month, year, quarter, week year, weeks in year, get/set, maximum , minimum etc. Get /Set is a very helpful feature available in Moment JS.

  4. Display:- Display provides formats to display date in different ways. There are methods available which tells the time from a given moment, from the current moment, difference between two moments etc. It allows to display date in String format, Array, Object, etc.

  5. Date Queries:- Date Queries has easy to use methods which tells if the date is greater or lesser than the input, in between the dates given, is a leap year, is a moment, is a date etc. It is very useful with date validation.

  6. Duration:- Durations is one of the important features in Moment JS. It basically handles length of the time for given units. The humanize method available displays date in a human readable format.

Some shorthands:-

Key Shorthand
years Y
quarter Q
months M
weeks w
days d
hours h
minutes m
seconds s
milliseconds ms