dayjs
dayjs copied to clipboard
Poor documentation or bug with local time display as string
console.log(dayjs())
... $M $W $d: Tue Nov 30 2021 19:17:28 GMT+0530 (India Standard Time) $m ...
console.log(dayjs().toString())
Tue, 30 Nov 2021 13:47:28 GMT
Huh? Calling Now shows local time, and calling As String on Now mysteriously turns it into GMT.
So how is one supposed to get a string of the local time?
I'm was having the same exact issue. This API is insanely inconsistent, and chocked full of gotchas. After 10 months of attempting to make things work, I decided to switch on to Luxon. Wow, massive difference. Each of Luxon's API methods does what you think it will do, and I haven't run into a single gotcha or nonsensical default as of yet. Having an API that can be reasoned about is paramount, especially with a complex topic as date/times.
toString will do the exactly same as (new Date()).toString() according to your system locale setting