hexo icon indicating copy to clipboard operation
hexo copied to clipboard

timezone的配置问题

Open aispin opened this issue 9 years ago • 10 comments

对于发布日期小时为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

aispin avatar Jul 27 '16 11:07 aispin

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

zhaohongxuan avatar Feb 24 '17 06:02 zhaohongxuan

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

sayll avatar May 04 '17 05:05 sayll

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

NoahDragon avatar May 04 '17 13:05 NoahDragon

@NoahDragon https://github.com/viosey/hexo-theme-material

sayll avatar May 04 '17 14:05 sayll

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

NoahDragon avatar May 04 '17 15:05 NoahDragon

@NoahDragon 我能为此做些什么?

sayll avatar May 04 '17 15:05 sayll

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

NoahDragon avatar May 04 '17 15:05 NoahDragon

@NoahDragon 嗯嗯,在此多谢。

sayll avatar May 04 '17 15:05 sayll

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.

seamlik avatar Apr 14 '18 05:04 seamlik

See also #3397 #2705

stevenjoezhang avatar Mar 09 '20 06:03 stevenjoezhang