In moment.js, if I write:
moment('1998').format('DD MMM YYYY');
I get 31 Dec 1997
. It seems like it rounds the date backwards. I would like to to say 01 Jan 1998
.
How can I do this? It doesn't seem to have much documentation for granularity.
This code should also give you a warning, as moment's use of 'guess which format type I'm using' function is deprecated.
It's probably guessing the right date, but due to the time difference in your timezone, it's giving this output. Try adding .utc()
to your call (moment('1998-01-01', 'YYYY-MM-DD').utc().format('DD MMM YYYY')
).