Date-fns: Customize the distance between the given dates in words

Created on 3 Oct 2018  路  3Comments  路  Source: date-fns/date-fns

Is there a way to customize the distance breakdown between the given dates in words?

_Example:_

screen shot 2018-10-03 at 7 59 49 am

Instead of having a distance of 45 minute show as about one hour, I would like anything between a minute and an hour to be shown in minutes.

Most helpful comment

I will leave my comment here with the hope that someone has the answer.

I want to have a response that is equal to the distanceInWordsStrict, but I don't want it to round the result. For example, if the diff is 1h35, I want it to result 1 hour 35 minutes or something like that. Can I do that with date-fns?

All 3 comments

89 minutes being formatted as "about 1 hour" is also rather imprecise. Could there be an option to always keep at least (roughly) two significant digits?

https://date-fns.org/v1.29.0/docs/distanceInWordsStrict seems to be what I was looking for :)

I will leave my comment here with the hope that someone has the answer.

I want to have a response that is equal to the distanceInWordsStrict, but I don't want it to round the result. For example, if the diff is 1h35, I want it to result 1 hour 35 minutes or something like that. Can I do that with date-fns?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amazing-gao picture amazing-gao  路  3Comments

Stradivario picture Stradivario  路  3Comments

pedrobrost picture pedrobrost  路  3Comments

sconway picture sconway  路  3Comments

ingro picture ingro  路  3Comments