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
Written by Adam Stankiewicz
Related protips
2 Responses
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#