Jump to content

Archived

This topic is now archived and is closed to further replies.

micah1701

unix time and day light savings

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

Share this post


Link to post
Share on other sites

×

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.