Moment.js
Js library for parsing time: https://momentjs.com/docs
5 flashcards · Programming Languages · by lakesare
What does moment("1995-12-25") do?
Moment tries to automatically determine date's format, and returns a Moment object.
What does moment("12-25-1995", "MM-DD-YYYY") do?
Parses string into Moment object according to the format you mention.
What does each return? moment().format(); moment().format("dddd, MMMM Do YYYY, h:mm:ss a"); moment('gibberish').format('YYYY MM DD');
moment().format(); //=> "2014-09-08T08:02:17-05:00" (ISO 8601) Current date string formatted in ISO 8601. moment().format("dddd, MMMM Do"); //=> "Sunday, February 14th" Current date string formatted in mentioned format. moment('gibberish').format('YYYY MM DD'); //=> "Invalid date"
How to get month ('MMMM') from the Moment object?
momentObject.format("MMMM"); //=> "January"
How to get month ('MMMM') from the "2014-09-08T08:02:17-05:00"?
turn our date string into a Moment object .format() it moment("2014-09-08T08:02:17-05:00").format("MMMM");