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.
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
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
[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
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.comVideos
01:47
How to Convert a Date String into a JavaScript Date Object with Ease!
How to Convert a Datetime String to a Date String in JavaScript
02:14
How to convert a date string to a JavaScript date object - YouTube
09:46
Parsing a date in JavaScript - YouTube
13:19
Parsing Date Time Strings - Moment.js Tutorial #2 - YouTube
Converting String to Date in JavaScript
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
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.
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()); ...
Current Millis
currentmillis.com
Current Millis ‐ Milliseconds since Unix Epoch
Convert milliseconds to date-time. Link to a moment.
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
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: