Managing local time is such a huge challenge when making webapps. There’s always going to be users from all over the world clocking in on different timezones. Basecamp’s local_time solves this problem in a elegant way – it doesn’t care how you store timezone, it interprets the users local time and prints it out on the view accordingly.
But, all hell breaks loose when you try to recreate this on the server side. Here there’s no information on what user is from what timezone.
And even if you persist the users timezone information, surprisingly Rails doesn’t come with an out of the box solution to offseting time(s).
Here’s a super simple way to convert a UTC time to a zone of your choice, by just inputting the offset.
{% gist 4d20c8989172351268173c4f16421208 %}
Subscribe to our newsletter
Get the latest updates from our team delivered directly to your inbox.
Related Posts
10 Gems in Ruby that you will love
Let's go back to basics with Ruby on Rails and see some of the Gems that we use everyday at skcript. #StartWithSkcript
#100DaysOfCommits
Our CTO, Swaathi, talks about our commitment to the #100DaysOfCommit challenge. Join us.
18 Python packages you should be using right now
Let us look at some python packages that will get you started on your machine learning path #StartWithSkcript