Moment.js Parsing String Last Updated : 27 Jun, 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 passed with a string to parse dates represented as strings. The moment() function is used to create a moment using a string. Syntax: moment(String) Parameters: It takes a string representing a specific date Returns: A Moment object Example 1: In this example, we will demonstrate the use of moment(): JavaScript import moment from 'moment'; let day = "2001-01-21" let date = moment(day); console.log(date.format("dddd, Do MMM YYYY, h:mm:ss A")); Output: Example 2: JavaScript import moment from 'moment'; let day = "2010-02-28 13:40:55" let date = moment(day); console.log(date.format("DD/MM/YYYY-H:mm:ss")); Output: Reference: https://momentjs.com/docs/#/parsing/string/ Comment More infoAdvertise with us Next Article Moment.js Parsing String A aayushmohansinha Follow Improve Article Tags : Web Technologies Node.js Moment.js Moment.js-Parse Similar Reads 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 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 Validation Date Validation in Moment.js moment#isValid is used to check whether a date is considered or not using Moment.js. This can be checked using moment#parsingFlags which returns an object in its response. Before proceeding, please install the moment.js library using the following command. Moment.js mome 2 min read Moment.js Parsing Now Moment.js is a date library for JavaScript that parses, validates, manipulates, and formats dates. We can use the moment() function passed to get the current date and time. The moment() function is used to create a moment with the current date and time. Syntax: moment() | moment(undefined) | moment( 1 min read 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 Like