Moment.js Parsing Defaults Last Updated : 07 Jul, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Moment.js is a date library for JavaScript that parses, validates, manipulates, and formats dates. We can use the moment() function by providing only a few parameters and the rest will default to the current day, month, or year and 0 for an hour, minute, second, and millisecond. The moment() function supplied with only a few parameters can be used to get the default values for the day, month, year, hour, minute, second, and millisecond. Syntax: moment(string1,string2) | moment(obj) Parameters: It takes in two strings, the first one specifying the date and the second specifying the format of the date. Apart from the strings, it may also take in an object specifying the date. Returns: A Moment object. Example 1: JavaScript import moment from 'moment'; let date = moment('02/2001/21', 'MM/YYYY/DD'); console.log(date.format('DD-MM-YYYY hh:mm:ss A')); Output:  Example 2: JavaScript import moment from 'moment'; let date = moment({year: 1999, hour: 14, minute: 45}); console.log(date.format('dddd, Do MMM YYYY, h:mm:ss A')); Output:  Reference: https://momentjs.com/docs/#/parsing/defaults/ Comment More infoAdvertise with us Next Article Moment.js Parsing Defaults A aayushmohansinha Follow Improve Article Tags : Web Technologies Node.js Moment.js Moment.js-Parse Similar Reads Moment.js Parsing Date Moment.js is a date library for JavaScript that parses, validates, manipulates, and formats dates. We can use the moment() function passed with an object to parse dates represented as Date object. The moment() function is used to create a moment using a Date object. Syntax: moment( Date ) Parameters 1 min read Moment.js Parsing Array Moment.js is a date library for JavaScript that parses, validates, manipulates, and formats dates. We can pass an array to the moment() function to parse a date represented in the form of an array. The moment() function is used to create a moment using an array. Syntax: moment(Number[]) Parameters: 1 min read Moment.js Parsing String + Formats Moment.js Parsing String + Formats is used when we are not sure of the exact format of an input date string. However, we can specify the possible formats in an array as a parameter for it to try and match. It is the same as String + Format, with the exception that this supports multiple formats. As 2 min read Moment.js Parsing Special Formats Moment.js is a JavaScript date library for parsing, validating, manipulating, and formatting dates. In this article, we will learn about the parsing of Special Formats in Moment.js. The ISO-8601 format is used as a standard for parsing the date and time. We can also specify HTML5 constants that can 2 min read Moment.js Parsing String + Format Moment.js Parsing String+Format is used when we want to parse a date string through the given format string. The parser will ignore the non-alphanumeric characters of the format. It returns the parsed date as a Moment object. Syntax: moment(String, String, Boolean); Parameters: This method accepts t 1 min read Like