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.
MomentJS provides various methods to parse the Date as listed below −
Sr.No. | Method & Syntax |
---|---|
1 | Nowmoment() |
2 | Stringmoment(string) |
3 | Objectmoment(object) |
4 | Datemoment(Date) |
5 | Arraymoment(Array[]) |
6 | Unix Timestampmoment(number) |
7 | Moment Clonemoment(Moment) |
8 | UTCmoment.utc() |
9 | parseZonemoment.parseZone() |
10 | Creation Datamoment().creationData(); |
11 | Defaultsvar m = moment({hour: 3, minute: 40, seconds: 10}); |
Leave a Reply