micah1701 Posted March 22, 2006 Share Posted March 22, 2006 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 = 1135296000Then, 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? ORDo 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 Quote Link to comment https://forums.phpfreaks.com/topic/5525-unix-time-and-day-light-savings/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.