How to Parse a Date and Time String in Node.JS

Text input can be tricky, and you may often receive more or less information than necessary for your task. For example, if you are given a request or invoice that needs to be logged in your systems, you may need to know only the hour and minutes or you could be required to input more in-depth data such as exact time of day and date. This API will parse a structured date and time string according to its parts.

Image for post
Image for post

To use this API, run this command to install the SDK:

npm install cloudmersive-validate-api-client --save

You can also add this snippet to your package.json:

"dependencies": {
"cloudmersive-validate-api-client": "^1.2.4"

Then, you can call the function:

var CloudmersiveValidateApiClient = require('cloudmersive-validate-api-client');
var defaultClient = CloudmersiveValidateApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveValidateApiClient.DateTimeApi();var input = new CloudmersiveValidateApiClient.DateTimeStandardizedParseRequest(); // DateTimeStandardizedParseRequest | Input requestvar callback = function(error, data, response) {
if (error) {
} else {
console.log('API called successfully. Returned data: ' + data);
apiInstance.dateTimeParseStandardDateTime(input, callback);

This will return the parsed date result, year, month, day, hour, minute, second, and day of the week.

You can retrieve the API Key from the at no cost and with no commitment. This will provide you with 800 monthly calls across our library of APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store