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
1Nowmoment()
2Stringmoment(string)
3Objectmoment(object)
4Datemoment(Date)
5Arraymoment(Array[])
6Unix Timestampmoment(number)
7Moment Clonemoment(Moment)
8UTCmoment.utc()
9parseZonemoment.parseZone()
10Creation Datamoment().creationData();
11Defaultsvar m = moment({hour: 3, minute: 40, seconds: 10});

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *