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

startOf('day') is returning 23:00 of the previous day #1096

Closed
will3942 opened this issue Sep 30, 2020 · 3 comments
Closed

startOf('day') is returning 23:00 of the previous day #1096

will3942 opened this issue Sep 30, 2020 · 3 comments

Comments

@will3942
Copy link

Describe the bug
When executing startOf('day') it is returning an ISO String where the time is 23:00 and the date is the previous day to the original Date object.

console.log(dayjs('2020-09-22T09:41:40.935Z').startOf('day').toISOString())
=> '2020-09-21T23:00:00.000Z'

Expected behavior
I would expect it to return '2020-09-22T00:00:00.000Z'

Information

  • Day.js Version: 1.9.1
  • OS: MacOS 10.14.6
  • Browser: Node.js 10.19.0
  • Time zone: GMT+1 (BST)
@iamkun
Copy link
Owner

iamkun commented Sep 30, 2020

Hi, this is the expected result as you are in GMT+1.

You can use .toDate() to check the real date.

@will3942
Copy link
Author

Ah, that's interesting. Thanks for the quick response!

@will3942 will3942 reopened this Sep 30, 2020
@jefferson-liew
Copy link

console.log(dayjs().startOf('day').toISOString())

returns the local time date 2024-01-26T00:00:00.000Z

instead of 2024-01-25T16:00:00.000Z

I am in GMT +8. How can I get the same output as @will3942 ?

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

3 participants