isSame() producing strange results
See original GitHub issuedayjs is making me feel like I’m going insane!
dayjs('2020-10-13T03:30:00.000Z').isSame('2020-10-12T04:53:43.427Z', 'day') // true
dayjs('2020-10-13T03:30:00.000Z').tz('UTC').isSame('2020-10-12T04:53:43.427Z', 'day') //false
Both dates are in UTC, so why is the first query incorrectly saying they’re in the same day?
Does dayjs()
assume a local timezone and isSame
doesn’t (or vice versa)?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
isSame() function in moment.js or Date Validation
So, I came across this moment.js and interested in knowing how to use isSame(). I tried implementing it but unsuccessful. Like :
Read more >Strange results from Deseq2
I'm getting strange results from DESeq2 results. I'm comparing 3 samples to another group of 3 samples, which I know is less than...
Read more >Weird result difference between release and debug even with
Recently I am studying cuda application. But when I use cuda on 2D second partial derivative calculation, it gives result mismatch between ...
Read more >Is Same - momentjs.com
But if the code runs slower it's possible that the moment created in isSame is measurably after the one created in moment() ,...
Read more >Averaging a measure over 3 Months - strange results
The Microsoft Matrix doesn't produce any meaningful numbers at all!! I've never had any issues with the Profitbase matrix reporting differently ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Have fun.
@iamkun, we are also struggling with this issue. Let me explain my point by giving an illustrative example. We have two dayjs objects, namely: date and breakStartTest, both of them have the the following value 2021-11-17 at 00.00 (local time) or 1637103600000 ms (see query below).
date.isSame(breakStartTest, 'day') //false
Moreover, we are in the CEST timezone. If both dayjs objects assume a local timezone then we expect isSame to return true, meaning that both occur on the same day. However, in our case isSame returns false. Our theory is that the date object (see code above) assumes local time while the breakStartTest object assume UTC. This theory is further confirmed by the query below in which we converted the date object to UTC:
date.utc().isSame(breakStartTest, 'day') //true
We have performed several tests, all of them gave the same result. I have attached an image below to illustrate my point (please excuse me for the artwork)
We kindly ask for clarification, thanks!