日期格式为 utc 月份日期和年份 (MMM DD, YYYY)
Date format to utc month date and year (MMM DD, YYYY)
您好,我正在尝试将 2017 年 3 月 29 日这个日期更改为 utc 日期:
这是我试过的:
var isoDate = new Date('Mar 29, 2017').toISOString();
//isoDate => returns "2017-03-28T22:00:00.000Z"
为什么我一开始得到的是 28T22 而不是 29?
Why am I getting 28T22 at the begginning instead of 29??
好吧,只是因为你在强迫它,你正在使用 .toISOString()
这将 return ISO 格式的日期。
因为CET中的Mar 29, 2017 T00:00:00.000Z
是ISO格式中的2017-03-28T22:00:00.000Z
。
您可以查看the difference between UTC and CET time zones了解更多详情。
您在 UTC 时区而不是 CET 时区进行转换。
CET 代表 欧洲中部时间。
UTC 被称为 通用时间 。
UTC 比 CET 晚 2 小时。
因此,当欧洲中部时间 11:00am 时,它将是 9am UTC。
toISOString()
将根据 UTC 和您所在时区之间的 adding/subtracting 时差显示日期。 (见评论)
您好,我正在尝试将 2017 年 3 月 29 日这个日期更改为 utc 日期:
这是我试过的:
var isoDate = new Date('Mar 29, 2017').toISOString();
//isoDate => returns "2017-03-28T22:00:00.000Z"
为什么我一开始得到的是 28T22 而不是 29?
Why am I getting 28T22 at the begginning instead of 29??
好吧,只是因为你在强迫它,你正在使用 .toISOString()
这将 return ISO 格式的日期。
因为CET中的Mar 29, 2017 T00:00:00.000Z
是ISO格式中的2017-03-28T22:00:00.000Z
。
您可以查看the difference between UTC and CET time zones了解更多详情。
您在 UTC 时区而不是 CET 时区进行转换。
CET 代表 欧洲中部时间。 UTC 被称为 通用时间 。
UTC 比 CET 晚 2 小时。
因此,当欧洲中部时间 11:00am 时,它将是 9am UTC。
toISOString()
将根据 UTC 和您所在时区之间的 adding/subtracting 时差显示日期。 (见评论)