Skip to content

How to get formatDistanceToNowStrict result into a specific format? #3661

Closed Answered by fturmel
niwatoridev asked this question in Q&A
Discussion options

You must be logged in to vote

I'd recommend you leverage either intervalToDuration or differenceInCalendarMonths and create your own formatting function for your specific use case.

Also, don't input your date string in that non-standard format. It will fail on Webkit (Safari) and Firefox, and create an Invalid Date.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#syntax
https://en.wikipedia.org/wiki/ISO_8601

Good luck!

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@niwatoridev
Comment options

@fturmel
Comment options

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