Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manipulate with utc0 time is wrong! #1778

Open
jetzhliu opened this issue Jan 23, 2022 · 3 comments
Open

Manipulate with utc0 time is wrong! #1778

jetzhliu opened this issue Jan 23, 2022 · 3 comments

Comments

@jetzhliu
Copy link

Describe the bug

dayjs('2022-01-23').utcOffset(0, true).format()
// print: 2022-01-23T00:00:00Z

dayjs('2022-01-23').utcOffset(0, true).add(1, 'minute').format()
// print 2022-01-22T16:01:00Z
// !!!

dayjs('2022-01-23').utcOffset(1, true).format()
// print 2022-01-23T00:00:00+01:00

dayjs('2022-01-23').utcOffset(1, true).add(1, 'minute').format()
// print 2022-01-23T00:01:00+01:00

Expected behavior

dayjs('2022-01-23').utcOffset(0, true).add(1, 'minute').format()
// should print:
// print: 2022-01-23T00:01:00Z

Information

  • Day.js Version 1.10.7
  • OS: MacOs
  • Browser chrome 96.0.4664.93
  • Time zone: GMT+0800
@jetzhliu
Copy link
Author

image

@jetzhliu
Copy link
Author

jetzhliu commented Nov 3, 2022

@iamkun do you have any idea?

@dongyuanxin
Copy link

@jetzhliu use utcOffset() after add()

const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')

dayjs.extend(utc)

console.log('>>> now is', dayjs('2022-10-24').utcOffset(0, true).format())
console.log('>>> now2 is', dayjs('2022-10-24').add(0, 'm').utcOffset(0, true).format())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants