Jump to content

unix time and day light savings


micah1701

Recommended Posts

So I built this extensive calendar application.
it works like outlook, allowing you to enter an event and have it repeat at whatever interval you choose.

It was all well and good until today when I realized I forgot one little thing. Day light savings.

my app works by taking the users starting date and time and converting it to unix time, something similar to:

strtotime("$_Post['year']-$_Post['month']-$_Post['day'] $_Post['hour']:$_Post['second'])

this gives a date of something like: $startDate = 1135296000

Then, to auto generate the future repeating event, I just add to that number.

$repeateRate = (60*60*24*7); // event repeats weekly
$event1 = $startDate;
$event2 = $event1 + $repeateRate;
$event3 = $event2 + $repeateRate; //you get the idea.

This was working great until I started adding dates that begin in March and repeat into the spring (Day Light Savings).

The unix time is created as above, but when I pull the info back out to show the user:
echo date("m/d/Y h:i", $event3);
All my dates that occur in the spring are off by +1 hour.

I'm not sure what my question is exactily.
I think it is: Do I adjust the times as I save them to the database - check to see if a specific events time occurrs during DLS and then adjust that time by + or - 1 hour?

OR

Do I leave my app the way it is, and adjust the time display when I pull the data out of the table. so when I show the user their time, adjust the time before I echo it.

I guess my question is, is the UnixTime correct and I need to adjust for the user OR is the unixTime wrong and I need to adjust it before inserting it into the dbase.

Any thoughts or opinions on how I should proceed? thanks
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.