strange mktime

strange mktime

am 17.08.2007 08:15:36 von Peter Wechtersbach

Hello, im found some strange behaviour. Someone knows whats is going on or
it is a bug?:

lets do like this:

three dates in timestamp:
27.10.2007: 1193436000
28.10.2007: 1193522400
29.10.2007: 1193612400

convert back:
1193436000: 27.10.2007 00:00:00
1193522400: 28.10.2007 00:00:00
1193612400: 29.10.2007 00:00:00

And one day is always 24 hours * 60 minutes * 60 secondes = 86400. So the
difference between these three dates in timestamp should also be the
same.But:
day2-day1 = 86400
day3-day2 = 90000

Here is my code, im using PHP Version 5.1.6:

echo ' three dates in timestamp:
';
$day1 = mktime(0, 0, 0, 10, 27, 2007);
$day2 = mktime(0, 0, 0, 10, 28, 2007);
$day3 = mktime(0, 0, 0, 10, 29, 2007);

echo '27.10.2007: '.$day1.'
';
echo '28.10.2007: '.$day2.'
';
echo '29.10.2007: '.$day3.'

';

echo 'convert back:
';
echo $day1.': '.date('d.m.Y H:i:s',$day1).'
';
echo $day2.': '.date('d.m.Y H:i:s',$day2).'
';
echo $day3.': '.date('d.m.Y H:i:s',$day3).'


';

echo 'And one day is always 24 hours * 60 minutes * 60 secondes =
86400. So the difference between these three dates in timestamp should also
be the same.But:
';

echo 'day2-day1 = '.($day2-$day1).'
';
echo 'day3-day2 = '.($day3-$day2).'
';

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: strange mktime

am 17.08.2007 21:24:23 von Michael Southworth

------=_Part_43451_18160816.1187378663323
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello,
Perhaps this has something to do with the daylight savings time calculations
being handled by the underlying system, since the difference is 1 hour;
60*60 = 3600. This could be checked to make sure that the total time
difference from one year remains the same, or that the first 6 months has 1
hour less and the second 6 months have one hour more.
see
http://en.wikipedia.org/wiki/Daylight_saving_time_around_the _world
for details. Apparently 29.10 is a common daylight savings date, here in the
states the actual date can change.

-Michael

On 8/16/07, Peter Wechtersbach wrote:
>
> Hello, im found some strange behaviour. Someone knows whats is going on or
> it is a bug?:
>
> lets do like this:
>
> three dates in timestamp:
> 27.10.2007: 1193436000
> 28.10.2007: 1193522400
> 29.10.2007: 1193612400
>
> convert back:
> 1193436000: 27.10.2007 00:00:00
> 1193522400: 28.10.2007 00:00:00
> 1193612400: 29.10.2007 00:00:00
>
> And one day is always 24 hours * 60 minutes * 60 secondes = 86400. So the
> difference between these three dates in timestamp should also be the
> same.But:
> day2-day1 = 86400
> day3-day2 = 90000
>
> Here is my code, im using PHP Version 5.1.6:
>
> echo ' three dates in timestamp:
';
> $day1 = mktime(0, 0, 0, 10, 27, 2007);
> $day2 = mktime(0, 0, 0, 10, 28, 2007);
> $day3 = mktime(0, 0, 0, 10, 29, 2007);
>
> echo '27.10.2007: '.$day1.'
';
> echo '28.10.2007: '.$day2.'
';
> echo '29.10.2007: '.$day3.'

';
>
> echo 'convert back:
';
> echo $day1.': '.date('d.m.Y H:i:s',$day1).'
';
> echo $day2.': '.date('d.m.Y H:i:s',$day2).'
';
> echo $day3.': '.date('d.m.Y H:i:s',$day3).'


';
>
> echo 'And one day is always 24 hours * 60 minutes * 60 secondes =
> 86400. So the difference between these three dates in timestamp should
> also
> be the same.But:
';
>
> echo 'day2-day1 = '.($day2-$day1).'
';
> echo 'day3-day2 = '.($day3-$day2).'
';
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

------=_Part_43451_18160816.1187378663323--