MomentJS - Parsing Date and Time



MomentJS has many easy to use methods which helps in parsing Date and Time. It can parse dates in the form of object, string, array, JavaScript native date object etc. This chapter discusses them in detail.

Parsing Date

MomentJS gives wrapper object as output when moment() is called. You can observe the following when you console the output in the browser.

Parsing Date

MomentJS provides various methods to parse the Date as listed below −

Sr.No. Method & Syntax
1 Now

moment()

2 String

moment(string)

3 Object

moment(object)

4 Date

moment(Date)

5 Array

moment(Array[])

6 Unix Timestamp

moment(number)

7 Moment Clone

moment(Moment)

8 UTC

moment.utc()

9 parseZone

moment.parseZone()

10 Creation Data

moment().creationData();

11 Defaults

var m = moment({hour: 3, minute: 40, seconds: 10});

Advertisements