bschultz Posted November 1, 2011 Share Posted November 1, 2011 <?php if(date('w') == 0) $str = 'today'; else $str = 'last sunday'; $timestamp = strtotime($str); //echo $timestamp; echo "<img src='brn_masthead.gif' width='500' /><br /><table border='1'><tr>"; echo "<tr><td align='center' width='140'><b>Sunday</b></td><td align='center' width='140'><b>Monday</b></td><td align='center' width='140'><b>Tuesday</b></td><td align='center' width='140'><b>Wednesday</b></td> <td align='center' width='140'><b>Thursday</b></td><td align='center' width='140'><b>Friday</b></td><td align='center' width='140'><b>Saturday</b></td></tr><tr>"; $j = 0; for($i = 0; $i < 14; $i++) { $thisdate = date('Y-m-d', $timestamp + ($i * (60 * 60 * 24))); ?> I've looked into mktime and checked the manual, but can't find anything that seems to work inside the loop. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/250216-how-can-adjust-this-code-to-account-for-daylight-savings-time/ Share on other sites More sharing options...
Psycho Posted November 1, 2011 Share Posted November 1, 2011 What, exactly, is it you are having a problem with. How is it "not working' and how do you want it to work differently? Quote Link to comment https://forums.phpfreaks.com/topic/250216-how-can-adjust-this-code-to-account-for-daylight-savings-time/#findComment-1283880 Share on other sites More sharing options...
bschultz Posted November 1, 2011 Author Share Posted November 1, 2011 It's a two week calendar. Everything worked up until this week. The events for the 6th (Sunday - first day of daylight savings time) are showing up on the column for Sunday AND the column for Monday, and every other day's content is showing up one day late (in the calendar format). Quote Link to comment https://forums.phpfreaks.com/topic/250216-how-can-adjust-this-code-to-account-for-daylight-savings-time/#findComment-1283881 Share on other sites More sharing options...
Psycho Posted November 1, 2011 Share Posted November 1, 2011 OK, after looking at the output I assume your issue is that you are getting 10-30 twice in the results. That is because you didn't specify an hour in your seed timestamp - so the start timestamp is set to midnight. Then, when you go forward 24 hours over the day where we "fall back" you are at 23:00 (11PM) of that same day. The solution is simple set your seed timestamp in the middle of the day. $str = 'last sunday 12PM'; Quote Link to comment https://forums.phpfreaks.com/topic/250216-how-can-adjust-this-code-to-account-for-daylight-savings-time/#findComment-1283886 Share on other sites More sharing options...
bschultz Posted November 1, 2011 Author Share Posted November 1, 2011 Well that was easy enough...learn something new each day! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/250216-how-can-adjust-this-code-to-account-for-daylight-savings-time/#findComment-1283895 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.