There is time zone support built into Rails.  It will involve:

1.  Migrating your times to UTC.
2.  Configuring your application to store data in UTC.
3.  Either transforming time to an offset, or allow users to specify a
timezone and then setting this in the session.

Check out:

http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/

In general, you want to avoid relying on server time because it links
your code to the timezone of the server.  It's best to store
everything in UTC.

HY

On Dec 3, 9:50 am, justin <[email protected]> wrote:
> Hello everyone,
>
> [This may be a Ruby question rather than a Heroku question; apologies
> in advance]
>
> I have a model object which represents an English football match:
>
> >> match
>
> => #<Game id: 1184, created_at: "2008-11-28 08:01:01", updated_at:
> "2008-12-03 09:28:38", date: "2008-12-06", home_team: "Fulham",
> away_team: "Man City", home_goals: nil, away_goals: nil,
> home_win_probability: 0.37037, draw_probability: 0.29412,
> away_win_probability: 0.35714, league_id: 1, kickoff: nil>
>
> I want to set the kickoff time to 3pm GMT ..
>
> >> match.kickoff=Time.utc(2008, 12, 6, 15, 0, 0)
>
> => Sat Dec 06 15:00:00 UTC 2008>> match.kickoff.gmtime
>
> => Sat Dec 06 15:00:00 UTC 2008>> match.save
>
> => true
>
> So far, so good; now let's reload the match ..
>
> >> match=Game.find(match.id)
>
> => #<Game id: 1184, created_at: "2008-11-28 08:01:01", updated_at:
> "2008-12-03 09:44:25", date: "2008-12-06", home_team: "Fulham",
> away_team: "Man City", home_goals: nil, away_goals: nil,
> home_win_probability: 0.37037, draw_probability: 0.29412,
> away_win_probability: 0.35714, league_id: 1, kickoff: "2008-12-06
> 15:00:00">
>
> .. and check the kickoff time ..
>
> >> match.kickoff.gmtime
>
> => Sat Dec 06 23:00:00 UTC 2008
>
> !!!
>
> I'm assuming Heroku's servers are set at GMT - 8 hours, somewhere on
> the US East Coast; when I set the time to 3pm, it's saved in the
> database as 3pm local time, which then reloads as 11pm GMT [8 hours
> difference].
>
> Can anyone shed some light on how to fix this ?
>
> Thanks in advance,
>
> Justin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to