The best string format for string parsing is the date ISO format together with the JavaScript Date object constructor.

Examples of ISO format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS.

But wait! Just using the "ISO format" doesn't work reliably by itself. String are sometimes parsed as UTC and sometimes as localtime (based on browser vendor and version). The best practice should always be to store dates as UTC and make computations as UTC.

To parse a date as UTC, append a Z - e.g.: new Date('2011-04-11T10:20:30Z').

To display a date in UTC, use .toUTCString(),
to display a date in user's local time, use .toString().

More info on MDN | Date and this answer.

For old Internet Explorer compatibility (IE versions less than 9 do not support ISO format in Date constructor), you should split datetime string representation to it's parts and then you can use constructor using datetime parts, e.g.: new Date('2011', '04' - 1, '11', '11', '51', '00'). Note that the number of the month must be 1 less.


Alternate method - use an appropriate library:

You can also take advantage of the library Moment.js that allows parsing date with the specified time zone.

Answer from Pavel Hodek on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › parse
Date.parse() - JavaScript | MDN
The Date.parse() static method parses a string representation of a date, and returns the date's timestamp.
🌐
W3Schools
w3schools.com › jsref › jsref_parse.asp
JavaScript Date parse() Method
❮ Previous JavaScript Date Reference Next ❯ · let ms = Date.parse("March 21, 2012"); Try it Yourself » · parse() parses a date string and returns the time difference since January 1, 1970. parse() returns the time difference in milliseconds.
Discussions

Parsing a string to a date in JavaScript - Stack Overflow
How can I convert a string to a Date object in JavaScript? var st = "date in some format" var dt = new Date(); var dt_st = // st in Date format, same as dt. More on stackoverflow.com
🌐 stackoverflow.com
[AskJS] Are there any JS libraries that will parse a date string and return a format string?
because almost everyone is more interested in just being able to parse the strings, not in getting out what format they were in Because it is not possible. What format is 09/09/09 01-01-01? Something could be done if you have multiple data entries with the same format, but even then if you are unlucky you wouldn't be able to determine it for sure. More on reddit.com
🌐 r/javascript
28
12
October 12, 2021
Parse Date to Specific Cultures (JavaScript)
You can’t import libraries for JavaScript in Electroneek?. I know you can use “Moment” inside the IDE, but I have to do other stuff inside my iteration (which runs inside of a “.js” file), and one of those things requires me to parse dates in each ... More on forum.electroneek.com
🌐 forum.electroneek.com
1
December 19, 2023
How to parse datetime string into JavaScript Date object
I’m getting a datetime string in this specific format: yyyy-MM-dd HH:mm:ss 2011-07-14 11:23:00 When I try to create a JavaScript Date object from this string, it doesn’t work properly. What’s the right approach to make… More on community.latenode.com
🌐 community.latenode.com
0
June 20, 2025
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
... Returns the numeric value ... 00:00:00 UTC, with leap seconds ignored. ... Parses a string representation of a date and returns the number of milliseconds since January 1, 1970 00:00:00 UTC, with leap seconds ignored....
🌐
Reality Ripple
udn.realityripple.com › docs › Web › JavaScript › Reference › Global_Objects › Date › parse
Date.parse() - JavaScript
The Date.parse() method parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC or NaN if the string is unrecognized or, in some cases, contains illegal date values (e.g.
Top answer
1 of 16
1087

The best string format for string parsing is the date ISO format together with the JavaScript Date object constructor.

Examples of ISO format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS.

But wait! Just using the "ISO format" doesn't work reliably by itself. String are sometimes parsed as UTC and sometimes as localtime (based on browser vendor and version). The best practice should always be to store dates as UTC and make computations as UTC.

To parse a date as UTC, append a Z - e.g.: new Date('2011-04-11T10:20:30Z').

To display a date in UTC, use .toUTCString(),
to display a date in user's local time, use .toString().

More info on MDN | Date and this answer.

For old Internet Explorer compatibility (IE versions less than 9 do not support ISO format in Date constructor), you should split datetime string representation to it's parts and then you can use constructor using datetime parts, e.g.: new Date('2011', '04' - 1, '11', '11', '51', '00'). Note that the number of the month must be 1 less.


Alternate method - use an appropriate library:

You can also take advantage of the library Moment.js that allows parsing date with the specified time zone.

2 of 16
452

Unfortunately I found out that

var mydate = new Date('2014-04-03');
console.log(mydate.toDateString());

returns "Wed Apr 02 2014". I know it sounds crazy, but it happens for some users.

The bulletproof solution is the following:

var parts ='2014-04-03'.split('-');
// Please pay attention to the month (parts[1]); JavaScript counts months from 0:
// January - 0, February - 1, etc.
var mydate = new Date(parts[0], parts[1] - 1, parts[2]); 
console.log(mydate.toDateString());

Find elsewhere
🌐
Zipy
zipy.ai › blog › parsing-a-string-to-a-date-in-javascript
parsing a string to a date in javascript
April 12, 2024 - The most straightforward way to convert a string to a date in JavaScript is using the Date.parse() method. This function takes a date string as an argument and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC.
🌐
Forum ElectroNeek
forum.electroneek.com › rpa automation › studio pro
Parse Date to Specific Cultures (JavaScript) - Studio Pro - Forum ElectroNeek
December 19, 2023 - Hi, I’m trying to parse a Date to a specific format (language/culture) without having to do lots of manual manipulations of the data, so I wanted to use the library “momentjs”. However, I tried many forms and I couldn’t…
🌐
Latenode
community.latenode.com › other questions › javascript
How to parse datetime string into JavaScript Date object - JavaScript - Latenode Official Community
June 20, 2025 - I’m getting a datetime string in this specific format: yyyy-MM-dd HH:mm:ss 2011-07-14 11:23:00 When I try to create a JavaScript Date object from this string, it doesn’t work properly. What’s the right approach to make…
🌐
Chris Pietschmann
pietschsoft.com › post › 2023 › 09 › 28 › javascript-parse-string-to-a-date
JavaScript: Parse a String to a Date | Chris Pietschmann
September 28, 2023 - The most reliable way to parse a date string in JavaScript is to use the ISO date format. ISO format can be in the form of YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS. However, there’s a caveat: JavaScript may interpret the input string as either UTC ...
🌐
EDUCBA
educba.com › home › software development › software development tutorials › javascript tutorial › javascript date parse
JavaScript Date parse | Learn How does Date Parsing work in JavaScript?
June 30, 2023 - Given string value 1 January 2019 to date.parse() method. It converts the string to date. But as discussed in the important note, the resultant date is always in milliseconds. So, we get an output of 154628100000. 154628100000 milliseconds from 1 January 1970. This is the base date for JavaScript.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Date and time
The call to Date.parse(str) parses the string in the given format and returns the timestamp (number of milliseconds from 1 Jan 1970 UTC+0). If the format is invalid, returns NaN. ... Date and time in JavaScript are represented with the Date object.
🌐
Tabnine
tabnine.com › home › how to use date.parse in javascript
How to Use Date.parse in JavaScript - Tabnine
July 25, 2024 - How to Use Date.parse in JavaScript ... a string representing a date, and returns the number of milliseconds that have elapsed between January 1, 1970, 00:00:00 UTC and the date provided....
🌐
freeCodeCamp
freecodecamp.org › news › javascript-string-to-date-date-parsing-in-js
JavaScript String to Date – Date Parsing in JS
June 29, 2022 - Date.parse() tells us the number of milliseconds that have elapsed since January 1, 1970. This is helpful when comparing multiple dates.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-date-parse-method
JavaScript Date parse() Method - GeeksforGeeks
July 11, 2025 - The JavaScript Date parse() method parses a date string and returns the number of milliseconds between the date string and midnight of January 1, 1970, UTC.
🌐
Turing
turing.com › kb › converting-string-to-date-in-js
Learn the Basics of Converting String to Date in JavaScript
By using the Date() function in JavaScript. By using parse(), UTC() which are static methods of the Date construct.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript | MDN
A string value representing a date, parsed and interpreted using the same algorithm implemented by Date.parse().
🌐
Swovo
swovo.com › blog › convert-string-to-date-javascript
Convert String to Date JavaScript - Swovo
The Date.parse() method takes a date-time string as a parameter and returns the date’s timestamp as a number. This allows you to convert a date string into a format that JavaScript can understand and manipulate.