question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

diff for same day (one UTC, one regular) gives 10800000

See original GitHub issue

Describe the bug UTC diff for same day gives 10800000

let dayjs = require('dayjs')
let utc = require('dayjs/plugin/utc')
dayjs.extend(utc)

console.log('diff', dayjs.utc('2021-06-07').diff('2021-06-07', 'days')) //gives 10800000. Expected: 0 or maybe 1, if timezone difference
console.log('diff', dayjs.utc('2021-06-07').diff(dayjs.utc('2021-06-07'), 'days')) //gives 0, correct

Expected behavior diff = 0 or maybe 1, if timezone difference

Information

  • Day.js Version 1.8.27
  • OS: Fedora
  • Browser nodejs 12
  • Time zone: GMT+3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
iamkuncommented, Aug 8, 2020

fixed

0reactions
justingolden21commented, Feb 22, 2022

How is one supposed to calculate the difference between two timezones? Get the UTC string with format ‘Z’ and then parse int?

EDIT: got it with .utcOffset() / 60

Read more comments on GitHub >

github_iconTop Results From Across the Web

DateAdd, DateDiff, and TimeZoneOffset functions in Power Apps
The DateDiff function returns the difference between two date/time values. The result is a whole number of units. For both functions, units can ......
Read more >
Time Zone Converter – Time Difference Calculator
Time Zone Converter – Time Difference Calculator. Provides time zone conversions taking into account Daylight Saving Time (DST), local time zone and accepts ......
Read more >
Difference between two time.Time objects - Stack Overflow
Question might be basic one. I have two time.Time objects and I want to get the difference between the two in terms of...
Read more >
Difference
This indicates the difference between two date-time in the specified unit. To get the difference in milliseconds, use dayjs#diff .
Read more >
Impala Date and Time Functions
The days value can be negative, which gives the same result as the ... For example, 11:59 PM on one day and 12:01...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found