note 110381 added to function.mktime
| From: | arthur dot nicoll at dundeecity dot gov dot uk | Date: | Wed, 17 Oct 2012 09:29:56 +0000 |
| Subject: | note 110381 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191345@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
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
----
Server IP: 87.124.126.49
Probable Submitter: 193.63.62.188
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- https://master.php.net/note/edit/110381
Del: integrated -- https://master.php.net/note/delete/110381/integrated
Del: useless -- https://master.php.net/note/delete/110381/useless
Del: bad code -- https://master.php.net/note/delete/110381/bad+code
Del: spam -- https://master.php.net/note/delete/110381/spam
Del: non-english -- https://master.php.net/note/delete/110381/non-english
Del: in docs -- https://master.php.net/note/delete/110381/in+docs
Del: other reasons-- https://master.php.net/note/delete/110381
Reject -- https://master.php.net/note/reject/110381
Search -- https://master.php.net/manage/user-notes.php