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

修复 toISOString() 引发的时区问题 #919

Closed
wants to merge 1 commit into from

Conversation

coder-xiaomo
Copy link

@coder-xiaomo coder-xiaomo commented Jul 2, 2024

中国是东八区,toISOString() 获取的是0时区时间。也就是说,在0点到8点,toISOString().split('T')[0] 取到的时间是前一天的日期。

中国是东八区,`toISOString()` 获取的是0时区时间。也就是说,在0点到8点,`toISOString().split('T')[0]` 取到的时间是前一天的时间。
@GRCmade
Copy link
Contributor

GRCmade commented Aug 29, 2024

你好,可以说一下你提交的代码具体解决什么问题吗?

@GRCmade GRCmade closed this Aug 29, 2024
@coder-xiaomo
Copy link
Author

@GRCmade 在凌晨0点到8点之间,这个时间获取错误。举例:

new Date('2024-08-31 00:00:00').toISOString()
// '2024-08-30T16:00:00.000Z'
new Date('2024-08-31 00:00:00').toISOString().split('T')[0]
// '2024-08-30'

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

Successfully merging this pull request may close these issues.

2 participants