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. Answer from oneandmillionvoices on reddit.com
🌐
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.
🌐
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.
Discussions

[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
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
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
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
🌐
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.
🌐
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....
🌐
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.
Find elsewhere
🌐
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…
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());

🌐
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…
🌐
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.
🌐
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 ...
🌐
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
July 10, 2025 - 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.
🌐
Sentry
sentry.io › sentry answers › javascript › parsing a string to a `date` in javascript
Parsing a string to a `Date` in JavaScript | Sentry
February 15, 2023 - If you can, use the full date and time in your date string. To parse a date string as UTC, append a “Z” to the end of the date:
🌐
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
forum.freecodecamp.org › javascript
Handling dates that can be successfully parsed by new Date(date_string) - JavaScript - The freeCodeCamp Forum
July 26, 2021 - Tell us what’s happening: I finished this project with the full functionality as the challenge asks but the test says Your project can handle dates that can be successfully parsed by new Date(date_string) and I don’t understand what this mean ? Your project link(s) solution: boilerplate-project-timestamp-2 - Replit Your browser information: User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36 Challenge: Time...
🌐
DEV Community
dev.to › onlinemsr › how-to-convert-string-to-date-in-javascript-p39
How to Convert String to Date in JavaScript - DEV Community
April 6, 2024 - It’s easy with the Date.parse() method! Just give it a date string that follows the rules, and it will give you back a magic number. This number is how many milliseconds have passed since the start of 1970 in UTC.