mrplatts Posted November 14, 2006 Share Posted November 14, 2006 I've written a script to set up calendar for a six-day rotating schedule. With some help here, I've written the code to get it basically working. here's my issue: I assign a date using [code]$s = mktime (0,0,0,$sm, $sd, $sy); [/code]Then display it using [code]print date('Y-m-d',$s);[/code]The timestamp that prints in the next column when I display [code]echo '<td>'.$s.'</td>';[/code]Is alwas exactly one hour off, Is there some sort of correction I need to do for DST? In fact, when I check it agains unixtimestamp.com. it is always a different date that appears. Oh, additionally, after about two months of dates a date repeats. (I'm adding 86400 to increment one day.)Sample output: 2006-08-24 Thursday11563920002006-08-25 Friday 11564784002006-08-26 Saturday1565648002006-08-27 Sunday 11566512002006-08-28 Monday 1156737600Very grateful for your input! Rich Quote Link to comment Share on other sites More sharing options...
btherl Posted November 14, 2006 Share Posted November 14, 2006 Instead of adding 86400, add 1 to the day value before passing to mktime(). mktime() will compensate for ends of months, ends of years and daylight savings, and generally do what you want it to do.Take a look at the comments in the online manual for more tips.http://sg.php.net/manual/en/function.date.phphttp://sg.php.net/manual/en/function.mktime.php Quote Link to comment 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.