Skip to content

Date strings with fractions of a second marked as invalid when formatting #2596

Discussion options

You must be logged in to vote

format only accepts a Date instance or a number (ms since Unix epoch) as its first argument. If you start with a string representation of a date, you need to parse it into a Date object first (with the parse or parseISO functions for example).
https://date-fns.org/v2.23.0/docs/format

Careful using strings in the Date constructor, it is discouraged by MDN because the implementation varies with each runtime.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@PontusMagnusson
Comment options

@fturmel
Comment options

@PontusMagnusson
Comment options

@fturmel
Comment options

Answer selected by PontusMagnusson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants