dayjs
dayjs copied to clipboard
do toISOString(true) in dayjs like in momentjs
We are currently in the process of migrating our legacy momentJS code over to dayJS and so far it is going well. However, we are running into issues when trying to replace 'toISOString()' function, since in momentJS we have an option of send 'True' parameter to prevent UTC conversion while in dayJS we don't have such an option.
Docs: https://momentjs.com/docs/#/displaying/as-iso-string/
in momentjs: moment().toISOString(true) // '2022-07-06T22:23:50.881+03:00'
in dayjs: dayjs().toISOString() // '2022-07-06T19:23:41.643Z'
In DayJS is there an equivalent function or how we can accomplish the same goal?
Hi, you can use format function like this:
const now = dayjs();
console.log(now.format("YYYY-MM-DDTHH:mm:ss.SSSZ"));