Moment.js Parsing Validation Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 moment#parsingFlags that results in an invalid date: overflow: It indicates a surge of a date field, for example, 30th February of the 13th Month.invalid month: It shows an invalid month name, such as January.empty: It means a string that is not parsable, for example, "this is a non-parsable string". null input: It denotes a null input.invalid format: It denotes an empty list of formats passed to moment() userInvalidated: It denotes a date explicitly created as invalid. Installation: npm install moment Syntax: moment(date: String).isValid() Parameters: moment().isValid() does not accept parameters. Return value: It returns a boolean value that tells whether a date is valid or not. Example 1: In this example, we will create an invalid date and check with moment#isValid. Filename: main.js JavaScript const moment = require('moment'); let m = moment("2022-10-10T10:20:90"); console.log(m.isValid()); Step to run the application: Open the terminal and type the following command. node main.js Output: false Example 2: In this example, we will create a valid date and check with moment#isValid. Filename: main.js JavaScript const moment = require('moment'); let m = moment("2022-10-10T10:20:50"); console.log(m.isValid()); Step to run the application: Open the terminal and type the following command. node main.js Output: true Reference: https://momentjs.com/docs/#/parsing/is-valid/ Comment More infoAdvertise with us Next Article Moment.js Parsing Validation D dishebhbhayana Follow Improve Article Tags : Technical Scripter Web Technologies Node.js Technical Scripter 2022 Moment.js Moment.js-Parse +2 More Similar Reads Moment.js Parsing String 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 take 1 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 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 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