How to convert time from one timezone to another

18 views
Skip to first unread message

Praveen BK

unread,
Apr 4, 2014, 2:37:28 AM4/4/14
to rubyonra...@googlegroups.com
Hello,

How to convert utc time to a time in a particular time zone. As I
need to display local time of timezone(-05:00).



Thank you,
Praveen

--
Posted via http://www.ruby-forum.com/.

mike2r

unread,
Apr 4, 2014, 9:38:26 AM4/4/14
to rubyonra...@googlegroups.com
use the ruby method local time.  in my example, i have an object post with an attribute created_at that is a date/time.  You display this in local time with formatting as follows:

<%= post.created_at.localtime.strftime("%-m/%-d/%Y at %-I:%M %p") %>

  
Reply all
Reply to author
Forward
0 new messages