Have some code to parse a string w/ time zone:
Time.strptime("5/28/19 14:26:36 Eastern Time (US & Canada)", '%m/%d/%y %H:%M:%S %Z')
The weird thing is that on my local machine, the result is: 2019-05-28 14:26:36 -0600
.
However when I run the same line on my Heroku staging server, the result is 2019-05-28 14:26:36 0000
.
Perhaps there is some system/Rails time zone configuration that differs between the two environments, but I would expect them to parse the same string correctly.
Using the same version of Ruby, Rails, and all gems on both environments.
Any thoughts?
CodePudding user response:
You should be using Time.zone.strptime
to take the timezone into consideration like
Time.zone.strptime("5/28/19 14:26:36 Eastern Time (US & Canada)", '%m/%d/%y %H:%M:%S %Z')