如何在Sails.js或Express.js中设置本地时区 [英] How to set local timezone in Sails.js or Express.js
本文介绍了如何在Sails.js或Express.js中设置本地时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
updatedAt:2014-07-06T15:00当我在帆上创建或更新记录时,将其写入updateAt :00.000Z
但我在格林尼治标准时间+2小时(本赛季),并进行更新在16:00时。
我在我的模型中声明的所有datetime字段都有同样的问题。
我可以在Sails(或最终Express)上设置正确的时区吗?
解决方案
放
process.env.TZ ='UTC'; //任何时区你想要的
在 config / bootstrap.js
When I create or update record on sails it write this at updateAt:
updatedAt: 2014-07-06T15:00:00.000Z
but I'm in GMT+2 hours (in this season) and update are performed at 16:00.
I have the same problem with all datetime fields declared in my models.
How can I set the right timezone on Sails (or eventually Express) ?
解决方案
The way I handled the problem after hours of research :
Put
process.env.TZ = 'UTC'; //whatever timezone you want
in config/bootstrap.js
这篇关于如何在Sails.js或Express.js中设置本地时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文