简体   繁体   中英

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 not converting date correctly

Blakes Seven's answer solved the issue locally, but when I deployed to AWS EC2, the problem reoccurred. Here are the steps I took to understand the issue:

  • I verified the Elastic Beanstalk instance was using the correct zip from S3 bucket. So the code fix is definitely live.
  • EC2 location: US East (N. Virginia)
  • The request location to MongoDB for records is the same for the local and live
  • 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.

So my questions are:

  • How can I verify that my EC2 is set to UTC time
  • 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. I solved it by using moment-timezone and force to 'Europe/Paris': moment.tz('Europe/Paris')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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