Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/258907-two-timestamps-give-same-date/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.