Hexo: timezone的配置问题

Created on 27 Jul 2016  ·  10Comments  ·  Source: hexojs/hexo

对于发布日期小时为0时的文章,本机编译和travis上编译出来的日期相差一天,在配置文件中指定了timezone依然有次问题。

Environment Info

Node version(node -v)

v5.12.0

_config.yml

timezone: Asia/Shanghai
...

日期设置示例,注意其中date的配置中小时为00

title: 手把手教你搭建ngrok服务-轻松外网调试本机站点
subtitle: "ngrok的核心功能:能够将你本机的HTTP服务(站点)或TCP服务,通过部署有ngrok服务的外网伺服器暴露给外网访问!"
cover: //img.aotu.io/mamboer/ngrok.jpg
date: 2016-02-19 00:55:35
categories: Web开发
tags:
  - ngrok
  - 反向代理
  - 调试

如上配置示例,当date2016-02-19 00:55:35时,在本地编译出来的文章路径为/2016/02/19,但是在travis上面变成了/2016/02/18

dates need-verify

Most helpful comment

I don't know if this solves the issue, but I always specify the timezone in the date of my posts. For example: 2018-04-14T13:00:38+08:00. This is the standard representation of combining date, time and timezone.

I propose that Hexo should always append the timezone in the generated date. This way it might be more flexible when the site is configured to display local time to visitors.

All 10 comments

我的把_config目录中的timezone配置去掉了就没问题了

现在我也只能通过timezone留空的办法了。

请问使用的是哪个主题呢?

@sayll 似乎是这段代码产生的问题
https://github.com/hexojs/hexo-front-matter/blob/HEAD@%7B2017-05-04T15:24:30Z%7D/lib/front_matter.js#L71

@NoahDragon 我能为此做些什么?

@sayll 从以上那段代码可以看出,front matter中的Date被认为是UTC时间。所以要使timezone运行正常,需要在Date中写入当前的UTC时间。这些都是从上面代码片段解读而来,等有时间我验证一下。

@NoahDragon 嗯嗯,在此多谢。

I don't know if this solves the issue, but I always specify the timezone in the date of my posts. For example: 2018-04-14T13:00:38+08:00. This is the standard representation of combining date, time and timezone.

I propose that Hexo should always append the timezone in the generated date. This way it might be more flexible when the site is configured to display local time to visitors.

See also #3397 #2705

Was this page helpful?
0 / 5 - 0 ratings

Related issues

testareas picture testareas  ·  3Comments

lushijie picture lushijie  ·  3Comments

demurgos picture demurgos  ·  3Comments

awulkan picture awulkan  ·  3Comments

jasoncheng911 picture jasoncheng911  ·  3Comments