lmcpeos Posted March 14, 2012 Share Posted March 14, 2012 Hi, Hope this is the right place for this... I have php routines that print itineraries. For some reason the timestamp (1351378800) returns the same date Sunday 28th October (2012) as the time stamp (1351465200). $count = 0; while ($count <= ($nights+1)) { echo date ('l', $startdate1)." (".$startdate1.")"; echo "<br>"; echo date ('jS F', $startdate1); $startdate1 += 86400; // more code } Any ideas? Many thanks, Peter Quote Link to comment https://forums.phpfreaks.com/topic/258907-two-timestamps-give-same-date/ Share on other sites More sharing options...
scootstah Posted March 14, 2012 Share Posted March 14, 2012 It doesn't show the same time for me. The second is 24 hours after the first. Quote Link to comment https://forums.phpfreaks.com/topic/258907-two-timestamps-give-same-date/#findComment-1327318 Share on other sites More sharing options...
Muddy_Funster Posted March 14, 2012 Share Posted March 14, 2012 more info please, and please use the or [code ] / [/code ] BBtags around your code. It seems like it's a flaw in your logic somewhere, could we see all the relevent code? Quote Link to comment https://forums.phpfreaks.com/topic/258907-two-timestamps-give-same-date/#findComment-1327320 Share on other sites More sharing options...
PFMaBiSmAd Posted March 14, 2012 Share Posted March 14, 2012 Depending on where you are at (you observed DST or not) there are not exactly 86400 seconds in each day. If you use strtotime() to do your date increment (i.e. '+1day') it should work. Quote Link to comment https://forums.phpfreaks.com/topic/258907-two-timestamps-give-same-date/#findComment-1327337 Share on other sites More sharing options...
salathe Posted March 14, 2012 Share Posted March 14, 2012 As PFMaBiSmAd said, sometimes there are not exactly 86,400 seconds in a day. Here's an example, in the Europe/London time zone. $start = strtotime('2012-10-28 00:00:00 Europe/London'); $end = strtotime('2012-10-29 00:00:00 Europe/London'); echo $end - $start; The output gives the number of seconds between those two consecutive midnights as 90000. This is correct because the start date is in British Summer Time (ahead of GMT by one hour), then 2 hours later at 2am the clocks went back to 1am into Greenwich Mean Time, and a whole 23 hours later we get to midnight of that day. This makes a total of 25 hours that have elapsed, which is 90,000 seconds. Similarly, when the clocks go forward on the 25th of March (again for Europe/London) there will only be 23 hours from midnight to midnight. Quote Link to comment https://forums.phpfreaks.com/topic/258907-two-timestamps-give-same-date/#findComment-1327446 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.