I have a file that was using the date-fns.formatISO9075 from date-fns.
const dateFns = require('date-fns')
dateFns.formatISO9075(anniversaryDateLessThanCurrent)
We're moving to day.js
But I am unclear how to replicate that?
I tried:
dayjs(anniversaryDateGreaterThanCurrent).format('YYYY-MM-DD HH:mm:ss.SSS')
But my test failed.
Any idea how to format that?
According to the date-fns docs, it appears that using the formatISO9075 function without any options results in the following
// Represent 18 September 2019 in ISO 9075 format:
const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52))
//=> '2019-09-18 19:00:52'
This would correspond with the following formatting -- 'YYYY-MM-DD HH:mm:ss'
Comparing this to the dayjs code that you posted,
dayjs(anniversaryDateGreaterThanCurrent).format('YYYY-MM-DD HH:mm:ss.SSS')
it's going to return milliseconds as well.
I would expect this to work as expected if you update the format string to
dayjs(anniversaryDateGreaterThanCurrent).format('YYYY-MM-DD HH:mm:ss')