-ji3uw
Last Updated: February 25, 2016
·
1.425K
· sheerun
Photo on 08.01.2013 at 04.15

Convert date represented as string between time zones

By combining parsing time in given time zone and getting time in different time zone you can easily convert any time represented in string to different time zone:

For example to get time in New York if in Warsaw is 13:27:

warsaw = ActiveSupport::TimeZone["Europe/Warsaw"].
  parse("Sun, 18 May 2012 13:27:25")
=> Sun, 18 May 2012 13:27:25 CEST +02:00

york = warsaw.in_time_zone("America/New_York")
=> Sun, 18 May 2012 07:27:25 EDT -04:00
Say Thanks
Respond

2 Responses
Add your response

307
971bb20678e83c73b15eb1e981ebe740

You mean warsaw.intimezone on line 2 or
dateinwarsaw = () on line1.

VariableTypo

over 1 year ago ·
315
Photo on 08.01.2013 at 04.15

@i-arindam I've fixed that, thank you :)

over 1 year ago ·