I'd like to sort out a dayjs problem I am experiencing. Right now, I'm out of clues and/or guesses of what can happen, apart from the bad timezone setting. But again, how could timezone play a role here, if I didn't even modify it anywhere in my code?
I'm having a dayjs
object, and I want to get the beginning of the day with it. When printing the output into console, I get:
d {
'$L': 'en',
'$d': 2021-03-18T22:00:00.000Z,
'$x': {},
'$y': 2021,
'$M': 2,
'$D': 19,
'$W': 5,
'$H': 0,
'$m': 0,
'$s': 0,
'$ms': 0
}
Efficiently that means that month, day, week, hour, minute, second, and millisecond options are set correctly (they are all zero), but the date field in $d
is absolutely wrong (it's shifted 2 hours back for some reason). How do I make the date update correctly as well? Please explain why does it happen so I will know how to deal with it in the future.
Using node.js
with express.js
to run day.js
on.
Node version is 15.8.0
Express version is 4.17.1
Dayjs version is 1.10.4
Many thanks in advance!
2021-03-19T00:00:00.000+02:00
. But in UTC, which is two hours behind, that's2021-03-18T22:00:00.000Z
– YongYYY-MM-DDT00:00:00.000
, as a start of a day without timezone in general, not the start of my day in particular (when converting to js date, dayjs takes exactly$d
)? – Suckerformat
function? – Lounge