Converting Time to IST in Rails

13 Jan


OK, in this blog I am going to say how to convert your time to Indian Standard Time. Most Rails servers return their time in UTC, but if you are developing application for a Indian firm they would like it in IST.

Lets say in your application you print your time on the webpage like this:

<%= %>

This will surely give the time in UTC like 2012-01-13 15:19:43 UTC, but you need it in IST, to do so add this method in our application helper

def ist(time)

In view just modify the code as follows

<%= ist %>

And thats it, you will get time like 2012-01-13 20:49:43 +0530

Leave a comment

Posted by on January 13, 2012 in Ruby, Ruby On Rails, Web Tech


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: