It seems that you are using Version 2.0 of date-fns, which is still in alpha (development) status currently.

What functions are available and how they work still seems to change frequently. For example, while in version v2.0.0-alpha.26 toDate() can handle string parameters, it cannot do that any longer in version v2.0.0-alpha.27. There is a new parseISO() function instead.

This should work now:

format(parseISO('2019-02-11T14:00:00'), 'MM/dd/yyyy')

However, while version 2 is still in beta, I would suggest using the stable version 1.x for now.

Answer from NineBerry on Stack Overflow
🌐
GitHub
github.com › date-fns › date-fns › issues › 1619
Unable to parse date string in given format · Issue #1619 · date-fns/date-fns
October 18, 2019 - const parse = require('date-fns/parse') const fr = require('date-fns/locale/fr') parse('jeudi 23 janvier 13:18:23', 'EEEE dd MMMM HH:mm:ss', Date(), { locale: fr })
Author   nicolas-goudry
🌐
GitHub
gist.github.com › krutoo › c88dc9259e0ff531f3a640d5c3c6f267
date-fns parse multiple formats · GitHub
date-fns parse multiple formats. GitHub Gist: instantly share code, notes, and snippets.
Discussions

Error: Can't resolve 'date-fns/format'
Why am I getting: Module not found: Error: Can't resolve 'date-fns/format' after installing date-fns like this: npm install date-fns --save I am requiring it like this: const format = r... More on github.com
🌐 github.com
15
November 8, 2018
Parse and format date in string
It seems that you are using Version 2.0 of date-fns, which is still in alpha (development) status currently. What functions are available and how they work still seems to change frequently. For example, while in version v2.0.0-alpha.26 toDate() can handle string parameters, it cannot do that any longer in version v2.0.0-alpha.27. There is a new parseISO... More on stackoverflow.com
🌐 stackoverflow.com
parse does seem to observe the reference date when parsing a 2-digit year with yyyy
I already created SR #1569 to advocate an option for strict parsing when using the function parse but I now discovered that parse also seems to have a strange behavior when not strictly parsing a d... More on github.com
🌐 github.com
9
June 19, 2020
Consider bringing back old parse
Hi all! Today I tried the latest 2.0.0-alpha release and started updating a project we have. Unfortunately for us, the new API of parse didn't fit any of the use cases we have and couldn't ... More on github.com
🌐 github.com
15
1
🌐
GitHub
github.com › date-fns › date-fns › blob › main › src › parseJSON › index.ts
date-fns/src/parseJSON/index.ts at main · date-fns/date-fns
export interface ParseJSONOptions<DateType extends Date = Date> extends ContextOptions<DateType> {} · /** * Converts a complete ISO date string in UTC time, the typical format for transmitting · * a date in JSON, to a JavaScript `Date` instance. * * This is a minimal implementation for converting dates retrieved from a JSON API to · * a `Date` instance which can be used with other functions in the `date-fns` library.
Author   date-fns
🌐
GitHub
github.com › date-fns › date-fns › issues › 980
Error: Can't resolve 'date-fns/format' · Issue #980 · date-fns/date-fns
November 8, 2018 - Why am I getting: Module not found: Error: Can't resolve 'date-fns/format' after installing date-fns like this: npm install date-fns --save I am requiring it like this: const format = r...
Author   joetidee
🌐
GitHub
gist.github.com › ariesmcrae › f428c74fdb5b5082f4e4654a359724f7
Typescript: How to parse a unix epoch date using date-fns library · GitHub
// npm install date-fns date-fns-tz import { fromUnixTime, } from 'date-fns'; import { utcToZonedTime, format as utcFormat } from 'date-fns-tz'; // Unix epoch timestamp is a string in milliseconds in UTC const unixTimestampString = '1692761130000'; // 2023-08-23 03:25:30.000Z const unixTimestamp = Number(unixTimestampString); const dateObject = fromUnixTime(unixTimestamp / 1000); // Divide by 1000 to get seconds const dateInUTC = utcToZonedTime(dateObject, 'UTC'); const formattedDateInUTC = utcFormat(dateInUTC, "yyyy-MM-dd_HH.mm.ss.SSS'Z'", { timeZone: 'UTC' }); console.log(`formattedDateInUTC
🌐
date-fns
date-fns.org › v3.5.0 › docs › add
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.
Find elsewhere
🌐
GitHub
github.com › prantlf › date-fns-timezone › blob › master › docs › API.md
date-fns-timezone/docs/API.md at master · prantlf/date-fns-timezone
Returns the date parsed from the date string using the given format string and converts the parsed date to the local time. ... To escape characters in the format string, wrap them in square brackets (e.g. [G]). Punctuation symbols (-:/.()) do ...
Author   prantlf
🌐
date-fns
date-fns.org › docs › Getting-Started
date-fns docs
date-fns provides the most comprehensive yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
🌐
GitHub
github.com › marnusw › date-fns-tz
GitHub - marnusw/date-fns-tz: Complementary library for date-fns v2 adding IANA time zone support · GitHub
format - Extends date-fns/format with support for all time zone tokens, including z..zzzz · toDate - Can be used to parse a Date from a date string representing time in any time zone · Usage with Android · Working with UTC or ISO date strings is easy, and so is working with JS dates when all times are displayed in a user's local time in the browser.
Starred by 1.2K users
Forked by 116 users
Languages   JavaScript 60.7% | TypeScript 39.3%
🌐
GitHub
gist.github.com › lucasfsduarte › c38d4904873679659be437bf8ad5e7b6
date-fns utils · GitHub
date-fns utils · Raw · date.ts · This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ·
🌐
GitHub
gist.github.com › ad7fe6e8b2e42742a3b099dfdbb9dacf
Working with JS Date and Date-fns library
Working with JS Date and Date-fns library · Raw · Date-FNS.js · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
GitHub
github.com › date-fns
date-fns · GitHub
Modern JavaScript date utility library. date-fns has 18 repositories available. Follow their code on GitHub.
🌐
GitHub
github.com › orgs › date-fns › discussions › 2759
parse vs new Date · date-fns · Discussion #2759
import { parse, parseISO } from "date-fns"; const str = "2018-11-13"; const strUTC = str + "Z"; // input interpreted as local time zone // Tue Nov 13 2018 00:00:00 GMT-0500 (Eastern Standard Time) console.log(new Date(2018, 10, 13)); console.log(parse(str, "yyyy-MM-dd", new Date())); console.log(parseISO(str)); // input interpreted as UTC // Mon Nov 12 2018 19:00:00 GMT-0500 (Eastern Standard Time) console.log(new Date(Date.UTC(2018, 10, 13))); console.log(new Date(str)); console.log(parse(strUTC, "yyyy-MM-ddX", new Date())); console.log(parseISO(strUTC));
🌐
npm
npmjs.com › package › date-fns-tz
date-fns-tz - npm
September 30, 2024 - format - Extends date-fns/format with support for all time zone tokens, including z..zzzz · toDate - Can be used to parse a Date from a date string representing time in any time zone · Usage with Android · Working with UTC or ISO date strings is easy, and so is working with JS dates when all times are displayed in a user's local time in the browser.
      » npm install date-fns-tz
    
Published   Sep 30, 2024
Version   3.2.0
Author   Marnus Weststrate
🌐
npm
npmjs.com › package › date-fns
date-fns - npm
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
🌐
CodeSandbox
codesandbox.io › s › date-fns-parse-example-uh2bi
date-fns-parse-example - CodeSandbox
May 26, 2021 - date-fns-parse-example by wesleylhandy using date-fns, react, react-dom, react-scripts
Published   May 26, 2021
Author   wesleylhandy
🌐
GitHub
github.com › date-fns › date-fns › issues › 1849
parse does seem to observe the reference date when parsing a 2-digit year with yyyy · Issue #1849 · date-fns/date-fns
June 19, 2020 - I already created SR #1569 to advocate an option for strict parsing when using the function parse but I now discovered that parse also seems to have a strange behavior when not strictly parsing a date. parse('06/19/20', 'MM/dd/yyyy', new...
Author   doberkofler
🌐
Envato Tuts+
code.tutsplus.com › home › javascript
Using date-fns for Easy Date Manipulation | Envato Tuts+
July 28, 2023 - We commonly need to parse dates from strings when dealing with user input or data from external sources. date-fns provides the parse() function for this purpose.