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

统一代码及数据中的时区 #101

Closed
Dream4ever opened this issue Nov 1, 2020 · 0 comments
Closed

统一代码及数据中的时区 #101

Dream4ever opened this issue Nov 1, 2020 · 0 comments
Labels
JS Javascript

Comments

@Dream4ever
Copy link
Owner

问题描述

最近在查看数据库中的内容时,发现一个用于记录日期的字段,所记录的日期并不是以中国所在的东八区为基准进行记录的,而是以格林威治标准时间为基准进行记录的,这样所记录的日期有可能比实际的国内日期要玩一天。

解决方案

采用 dayjs 这个库来解析时间,问题就解决了。

因为 dayjs 这个库默认会使用计算机所在地区的本地时间,所以用这个库来实现所有时间相关的需求,就不会有时区问题了。

By default, Day.js parses and displays in local time.

@Dream4ever Dream4ever changed the title 统一代码中的时间 统一代码及数据中的时区 Nov 1, 2020
@Dream4ever Dream4ever added the JS Javascript label Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS Javascript
Projects
None yet
Development

No branches or pull requests

1 participant