note 110381 modified in function.mktime by danbrown
| From: | danbrown@php.net | Date: | Wed, 17 Oct 2012 21:18:20 +0000 |
| Subject: | note 110381 modified in function.mktime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191367@lists.php.net to get a copy of this message | ||
I do a lot of work using dates and times.
I use mktime() a lot. One wee word of caution over excessive use of incrementing the day parameter.
Something I do quite a lot and works great for reasonable ranges.
I recently found, however, that the function gave erroneous results when too many days were added
(i.e. around 6 months worth).
Changed to using mktime for the basic date then adding the required seconds to the integer datetime
value.
e.g. instead of
<?php
for ($i=0; $i<$no_of_four_week_periods,$i++)
{
$curdatetm = mktime(0,0,0,4,(1+($i*28)),$curyr);
}
?>
.. try something like ..
<?php
$basedatetm = mktime(0,0,0,4,1,$curyr);
for ($i=0; $i<$no_of_four_week_periods,$i++)
{
$cudatetm = $basedatetm + ($i*28*24*60*60);
}
?>
cheers
--was--
I do a lot of work using dates and times.
I use mktime() a lot. One wee word of caution over excessive use of incrementing the day parameter.
Something I do quite a lot and works great for reasonable ranges.
I recently found, however, that the function gave erroneous results when too many days were added
(i.e. around 6 months worth).
Changed to using mktime for the basic date then adding the required seconds to the integer datetime
value.
e.g. instead of
for ($i=0; $i<$no_of_four_week_periods,$i++)
{
$curdatetm = mktime(0,0,0,4,(1+($i*28)),$curyr);
}
.. try something like ..
$basedatetm = mktime(0,0,0,4,1,$curyr);
for ($i=0; $i<$no_of_four_week_periods,$i++)
{
$cudatetm = $basedatetm + ($i*28*24*60*60);
}
cheers
http://php.net/manual/en/function.mktime.php