Node.js Date.isValid() API Last Updated : 27 Jan, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The date-and-time.Date.isValid() is a minimalist collection of functions for manipulating JS date and time module which is used to validate the particular date and time with its string format. Required Module: Install the module by npm or used it locally. By using npm.npm install date-and-time --saveBy using CDN link.<script src="/https/www.geeksforgeeks.org/path/to/date-and-time.min.js"></script>Syntax: isValid(arg1[, arg2])Parameters: This method takes the following arguments as parameters: arg1: It is the date and time object.arg2: It is the string format of the given date.Return Value: This method returns true if and only if the terms are validated. Example 1: index.js // Node.js program to demonstrate the // Date.isValid() method // Importing date-and-time module const date = require('date-and-time') // Validating the terms // by using date.isValid() method const status = date.isValid('29-02-2015', 'DD-MM-YYYY'); // Display the result if(status) console.log("Date is valid") else console.log("Date is not invalid") Run the index.js file using the following command: node index.jsOutput: Date is not invalidExample 2: index.js // Node.js program to demonstrate the // Date.isValid() method // Importing date-and-time module const date = require('date-and-time') // Pre parsing the date and time // by using preparse() method const result = date.preparse('2015/01/02 23:14:05', 'YYYY/MM/DD HH:mm:ss'); // Validating the terms // by using date.isValid() method const status = date.isValid(result); // Display the result if(status) console.log("Date is valid") else console.log("Date is not invalid") Run the index.js file using the following command: node index.jsOutput: Date is valid Reference: https://github.com/knowledgecode/date-and-time Comment More infoAdvertise with us Next Article Node.js Date.isValid() API R rohitprasad3 Follow Improve Article Tags : Web Technologies Node.js NodeJS-API NodeJS date-time Similar Reads Node.js Date.format() API The date-and-time.Date.format() is a minimalist collection of functions for manipulating JS date and time module which is used to format the date according to a certain pattern. Required Module: Install the module by npm or used it locally.By using npm.npm install date-and-time --saveBy using CDN li 2 min read Node.js Date.parse() API The date-and-time.Date.parse() is a minimalist collection of functions for manipulating JS date and time module which is used to parse the date according to a certain pattern. Required Module: Install the module by npm or used it locally. By using npm.npm install date-and-time --saveBy using CDN lin 2 min read Moment.js Customize Invalid Date The Locale#invalidDate in Moment.js: The invalidate property should be a string, a replacement for the "Invalid Date" message you want to customize. Before proceeding, please install the moment.js library using the following command. Installation: npm install moment Syntax: const moment = require('m 2 min read Node.js Date.compile() API The date-and-time.Date.compile() is a minimalist collection of functions for manipulating JS date and time module which is used to compile a format string for the parser. Required Module: Install the module by npm or used it locally. By using npm.npm install date-and-time --saveBy using CDN link. 2 min read Node.js Date.addDays() API The date-and-time.Date.addDays() is a minimalist collection of functions for manipulating JS date and time module which is used to add the extra Days to the existing date and time. Required Module: Install the module by npm or used it locally. By using npm.npm install date-and-time --saveBy using CD 2 min read Like