# Timezone question

**URL:** <https://www.ruby-forum.com/t/timezone-question/158924>\
**Category:** Rails\
**Created:** [January 29, 2009, 2:13pm UTC](https://www.ruby-forum.com/t/timezone-question/158924 "2009-01-29T14:13:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephen\_OSD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/df788c/32.png) [@stephen\_OSD](https://www.ruby-forum.com/u/stephen_OSD)\
**Post date:** [January 29, 2009, 2:13pm UTC](https://www.ruby-forum.com/t/timezone-question/158924/1 "2009-01-29T14:13:03Z")

</div>

I have an app that stores appointments.

Appointments can recur daily, weekly etc or just be one off.

The application needs to notify users 15 minutes before each  
appointment.

Now, I know that I can use various Rails 2.1 features to help with  
TimeZones such as Time.zones, but what I am not sure about is daylight  
savings and these recurring reminders and people changing their  
timezones.

Lets say a user creates a daily reminder for 1pm in their timezone,  
say UTC -5 - ActiveRecord stores it at 6pm UTC.

Later in the year, due to daylight savings, their timezone becomes UTC  
-4, and all of a sudden, their appointment shifts by 1 hour.

Also, if a user flies off on business, and their timezone becomes UTC  
+5, all the appointments will be totally at the wrong time.

I am wondering what the best practice for this sort of scenario is?  
Should I always store local times in my database (ie if a user wants  
an appointment at 1pm, just store 1pm) and then the logic that sends  
reminders needs to get a time and adjust it to UTC to figure out when  
to send the reminder? That allows me to change reminders, and handle  
daylight savings correctly, at the expense of complex reminder logic.

I struggle to think of a way of handling daylight saving around daily  
appointments etc if I store appointments normalised to UTC in my  
database?

Opinions, comments and best practices all appreciated!

Thanks,

Stephen.

---

<div class="post-metadata">

**Author:** ![stephen\_OSD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/df788c/32.png) [@stephen\_OSD](https://www.ruby-forum.com/u/stephen_OSD)\
**Post date:** [January 29, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/timezone-question/158924/2 "2009-01-29T15:07:37Z")

</div>

On Thu, Jan 29, 2009 at 3:11 PM, stephen O’D  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> savings and these recurring reminders and people changing their
> 
> Opinions, comments and best practices all appreciated!
> 
> Thanks,
> 
> Stephen.
> 
> >

I haven’t worked with time zones yet but a quick search returned this  
[http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/](http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/) which  
has  
some mentions of daylight savings.

–  
Andrew T.  
[http://ramblingsonrails.com](http://ramblingsonrails.com)  
[http://www.linkedin.com/in/andrewtimberlake](http://www.linkedin.com/in/andrewtimberlake)

“I have never let my schooling interfere with my education” - Mark Twain

---

<div class="post-metadata">

**Author:** ![stephen\_OSD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/df788c/32.png) [@stephen\_OSD](https://www.ruby-forum.com/u/stephen_OSD)\
**Post date:** [January 29, 2009, 4:00pm UTC](https://www.ruby-forum.com/t/timezone-question/158924/3 "2009-01-29T16:00:55Z")

</div>

> I haven’t worked with time zones yet but a quick search returned thishttp://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/which has  
> some mentions of daylight savings.

Yea I have been through one. Its helps with one off events, but not  
recurring ones or if someone needs to change their timezone, which  
pretty much turns it all on its head. I am hoping someone has some  
experience of what I want to do and can share some lessons learned or  
tricks they used.
