Date-fns: Formatting completely broken

Created on 17 Sep 2019  路  3Comments  路  Source: date-fns/date-fns

I am running version 2.2.1, and look at the following output from the node REPL:

> const format = require('date-fns').format
undefined
> format(new Date(), 'EEEE')
'2222'
> format(new Date(), 'cccc LLLL do yyyy')
'cccc LLLL 2nd yyyy'
> format(new Date(), 'EEEE MMMM do YYYY')
'2222 September 2nd 2019'
> format(new Date(), 'EEEE MMMM do YYYY', { locale: 'en-US'})
'2222 September 2nd 2019'

Am I missing something totally from the docs, or what on earth could be causing this?

Most helpful comment

@fkabinoff I found my problem. Basically one of my other deps was installing an older version of date-fns, and there was a collision. I wiped my node_modules and re-installed, and now things are working as expected.

All 3 comments

So to add to this, if I start up a completely different project, and install date-fns, formatting works. So there must be some kind of conflict in my node_modules.

Does anyone have any idea what could cause this?

I'm having the same issue. Works with v1 in my project, but I've tried 2.2.1 and 2.1.0 so far, and format doesn't work correctly in either.
format(0, 'dd') // should be 'Su', but is '31' instead.

@fkabinoff I found my problem. Basically one of my other deps was installing an older version of date-fns, and there was a collision. I wiped my node_modules and re-installed, and now things are working as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ingro picture ingro  路  3Comments

Vincz picture Vincz  路  3Comments

sconway picture sconway  路  3Comments

tkrotoff picture tkrotoff  路  3Comments

rosieks picture rosieks  路  3Comments