🌐
Day.js
day.js.org
Day.js · 2kB JavaScript date utility library
Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API.
中文
中文文档 - 2kB 大小的 JavaScript 时间日期库
Format · Day.js
Get the formatted date according to the string of tokens passed in.
String + Format
If you know the format of an input string, you can use that to parse a date.
Docs
Day.js was designed to work both in the browser and in Node.js.
🌐
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 - The string that you want to parse into a Date should match this format or a portion of this format. The “T” character separates the date from the time portion of the string. The “Z” character is the UTC offset representation. UTC is Coordinated Universal Time, which is the primary time standard used to regulate times worldwide.
Discussions

JavaScript: how to convert a string to a formatted date?
You can check out the JavaScript Date object. You can create a Date object multiple ways, including passing in the exact string in your question: new Date('1977-04-22');. From there, the Date object has a few built in formatting functions like date.toDateString() which outputs Fri Apr 22 1977. (Be careful though. At the moment, for me it outputs 'Thu Apr 21 1977' since creating the date object with a string defaults to UTC time but the output is in my local timezone). https://css-tricks.com/everything-you-need-to-know-about-date-in-javascript/ and other Google results give more details about how to use the Date object. More on reddit.com
🌐 r/learnprogramming
7
2
May 21, 2020
Javascript Makes Me Cry: Turning a Date into a String
With the exception of the naming of methods, everything you are complaining about is inherited directly from C/POSIX. Have a look at the definition of struct tm from and see if it's familiar. This interface dates back decades, to at least the early 1980s BSD Unix 2.x. More on reddit.com
🌐 r/javascript
87
3
May 29, 2013
[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
new Date() works in Chrome but throws 'Invalid date' in Firefox

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date

Note: Parsing of date strings with the Date constructor (and Date.parse(), which works the same way) is strongly discouraged due to browser differences and inconsistencies.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

my guess is that chrome accepts a space in the date but firefox does not.

new Date('2020-10-19 07:57:52+00:00')

works for me

More on reddit.com
🌐 r/firefox
35
81
July 28, 2019
🌐
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 ...
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-parse-a-string-to-a-date-object-in-javascript.php
How to Parse a String to a Date Object in JavaScript
// Sample date string var str = '2021-10-08'; // Ceating the date object var date = new Date(str); console.log(date);
🌐
npm
npmjs.com › package › date-fns
date-fns - npm
Immutable & Pure: Built using pure functions and always returns a new date instance. TypeScript: The library is 100% TypeScript with brand-new handcrafted types. I18n: Dozens of locales. Include only what you need. ... import { compareAsc, format } from "date-fns"; format(new Date(2014, 1, 11), "yyyy-MM-dd"); //=> '2014-02-11' const dates = [ new Date(1995, 6, 2), new Date(1987, 1, 11), new Date(1989, 6, 10), ]; dates.sort(compareAsc); //=> [ // Wed Feb 11 1987 00:00:00, // Mon Jul 10 1989 00:00:00, // Sun Jul 02 1995 00:00:00 // ]
      » npm install date-fns
    
Published   Sep 17, 2024
Version   4.1.0
🌐
Zipy
zipy.ai › blog › parsing-a-string-to-a-date-in-javascript
parsing a string to a date in javascript
April 12, 2024 - Dates and times are fundamental to many web applications, from blogs and social media platforms to e-commerce sites tracking order deliveries. JavaScript provides several built-in functions and methods to handle dates, but converting a string representation of a date into a Date object can sometimes be tricky due to different date formats and locales.
🌐
Scaler
scaler.com › home › topics › convert string to date in javascript
Convert String to Date in JavaScript - Scaler Topics
January 10, 2024 - There is a class in JavaScript called the Date class. You can use this function to get the current date and time of the local system. You can also use this class's constructor to convert a date value from string data type to Date data type.
Find elsewhere
🌐
SPGuides
spguides.com › convert-string-to-date-in-typescript
How to Convert String to Date in TypeScript?
February 6, 2024 - Provides a suite of functions similar to Moment.js but with a focus on a modular approach, allowing developers to import only the functions they need. ... Use moment() to create a date object from a string.
🌐
JavaScript in Plain English
javascript.plainenglish.io › how-to-convert-a-string-to-a-date-object-in-javascript-58effc92440a
How to Convert a String to a Date Object in JavaScript? | by John Au-Yeung | JavaScript in Plain English
November 29, 2021 - In this article, we’ll look at how to convert a date string to a date object in JavaScript. One way to create a JavaScript date object from a date string is to extract the date parts from the date string and pass them all into the Date constructor.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toUTCString
Date.prototype.toUTCString() - JavaScript | MDN
July 10, 2025 - The toUTCString() method of Date instances returns a string representing this date in the RFC 7231 format, with negative years allowed. The timezone is always UTC. toGMTString() is an alias of this method. const event = new Date("14 Jun 2017 00:00:00 PDT"); console.log(event.toUTCString()); ...
🌐
Bugfender
bugfender.com › blog › javascript-date-and-time
The Definitive Guide to JavaScript Date and Time | Bugfender
February 18, 2025 - The simplest and most effective method to get the current date into a JavaScript string is using the toLocalDateString() method from the Date object.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-format-a-date-with-javascript-date-formatting-in-js
How to Format a Date with JavaScript – Date Formatting in JS
November 7, 2024 - JavaScript provides a few built-in methods to format dates conveniently. Let's take a look at some of these methods: toDateString(): This method converts the date portion of a Date object into a human-readable string format.
🌐
date-fns
date-fns.org
date-fns - modern JavaScript date utility library
date-fns provides the most comprehensive yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
🌐
Twelve Data
twelvedata.com › docs
API Documentation - Twelve Data
1. &symbol=AAPL&start_date=2019-08-09T15:50:00&… Returns all records starting from 2019-08-09T15:50:00 New York time up to current date
🌐
Code Beautify
codebeautify.org › blog › how-to-convert-string-to-date-using-to-javascript
How to Convert String to Date Using to Javascript
February 22, 2024 - The simplest way to convert a string to a date in JavaScript is by using the new Date() constructor. It automatically parses the provided string and creates a Date object. The Date.parse() method parses a string representation of a date and ...
🌐
NestJS
docs.nestjs.com › pipes
Documentation | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
🌐
Day.js
day.js.org › docs › en › parse › string-format
String + Format · Day.js
If you know the format of an input string, you can use that to parse a date.
🌐
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 › js › js_date_formats.asp
W3Schools.com
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... The ISO format follows a strict standard in JavaScript. The other formats are not so well defined and might be browser specific. Independent of input format, JavaScript will (by default) output dates in full text string format: