简体   繁体   English

每天在JS时刻关闭AWS EC2 UTC时区转换

[英]AWS EC2 UTC timezone conversion off by a day with moment JS

Yesterday I posted this question about MongoDB UTC record timestamp issues when using MomentJS : 昨天我发布了有关使用MomentJS时MongoDB UTC记录时间戳记问题的问题:

MomentJS not converting date correctly MomentJS无法正确转换日期

Blakes Seven's answer solved the issue locally, but when I deployed to AWS EC2, the problem reoccurred. Blakes Seven的答案在本地解决了该问题,但是当我部署到AWS EC2时,该问题再次发生。 Here are the steps I took to understand the issue: 这是我为了解问题所采取的步骤:

  • I verified the Elastic Beanstalk instance was using the correct zip from S3 bucket. 我验证了Elastic Beanstalk实例是否使用了S3存储桶中的正确zip So the code fix is definitely live. 因此,代码修复肯定是实时的。
  • EC2 location: US East (N. Virginia) EC2位置: US East (N. Virginia)
  • The request location to MongoDB for records is the same for the local and live 向MongoDB记录的请求位置对于本地和实时是相同的
  • Launch Time: October 21, 2015 at 4:51:31 PM UTC-4 (2684 hours) : I can't find the actual time zone config of my EC2, but this tells me it's UTC. 发布时间: October 21, 2015 at 4:51:31 PM UTC-4 (2684 hours) :我找不到EC2的实际时区配置,但这告诉我它是UTC。

So my questions are: 所以我的问题是:

  • How can I verify that my EC2 is set to UTC time 如何验证我的EC2已设置为UTC时间
  • Is the server timezone even the issue? 服务器时区甚至是问题吗? Somehow the dates aren't being read or parsed correctly 不知何故,日期无法正确读取或解析

I have a simular issue. 我有一个类似的问题。 Everything was going fine with moment.locale('fr') but wen wrong on AWS EBS/EC2. 使用moment.locale('fr')一切都很好,但是在AWS EBS / EC2上却出错。 I solved it by using moment-timezone and force to 'Europe/Paris': moment.tz('Europe/Paris') 我通过使用moment-timezone并强制使用“ Europe / Paris”解决了这一问题: moment.tz('Europe/Paris')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM