I am new to date-fns. I used to be using of moment js. However, I was trying date-fns because a lot of articles said that it is better, faster, etc. Hence, I start to play around with date-fns and got really confused with the main page documentation.
import { format, formatDistance, formatRelative, subDays } from 'date-fns'
format(new Date(), '[Today is a] dddd')
//=> "Today is a Sunday"
etc etc
I tried this on my project a lot of times and instead of returning Sunday, it returns 0007. While doing some more research and reading the documentations inside, I found that the correct one should be format(new Date(), '[Today is a] EEEE') to be able to return the name of the day. There is no pattern at all for dddd.
Hence, I think the main page should probably be updated. Thank you.
I am new to date-fns. I used to be using of moment js. However, I was trying date-fns because a lot of articles said that it is better, faster, etc. Hence, I start to play around with date-fns and got really confused with the main page documentation.
I tried this on my project a lot of times and instead of returning
Sunday
, it returns0007
. While doing some more research and reading the documentations inside, I found that the correct one should beformat(new Date(), '[Today is a] EEEE')
to be able to return the name of the day. There is no pattern at all fordddd
.Hence, I think the main page should probably be updated. Thank you.