Last Updated: February 25, 2016
·
1.851K
· sheerun

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

2 Responses
Add your response

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

VariableTypo

over 1 year ago ·

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

over 1 year ago ·