note 100263 added to function.mktime
| From: | olev at araamat dot org | Date: | Tue, 05 Oct 2010 01:50:30 +0000 |
| Subject: | note 100263 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172959@lists.php.net to get a copy of this message | ||
The example by 'contact at phpmember dot com' doesn't work as expected.
<?php
# the author used
$days = floor((time()-mktime(null,null,null,1,0,date("Y")))/86400);
# but presumably wanted to achieve smth like
$days =
floor((time()-mktime(date('H'),date('i'),date('s'),1,1))/86400);
?>
1) Using 'null' as an argument in mktime() doesn't have the effect of omitting an
argument. It becomes 0, not the current value. The manual says 'Arguments may be left out in
order from right to left; any arguments thus omitted will be set to the current value according to
the local date and time.'
2) Setting days to 0 means the last day of the previous month. Thus the example gives wrong results
(adds 1 day).
3) The last argument is unnecessary, omitting it would also set the year to the current value.
----
Server IP: 217.146.68.100
Probable Submitter: 83.178.58.14
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- https://master.php.net/note/edit/100263
Del: integrated -- https://master.php.net/note/delete/100263/integrated
Del: useless -- https://master.php.net/note/delete/100263/useless
Del: bad code -- https://master.php.net/note/delete/100263/bad+code
Del: spam -- https://master.php.net/note/delete/100263/spam
Del: non-english -- https://master.php.net/note/delete/100263/non-english
Del: in docs -- https://master.php.net/note/delete/100263/in+docs
Del: other reasons-- https://master.php.net/note/delete/100263
Reject -- https://master.php.net/note/reject/100263
Search -- https://master.php.net/manage/user-notes.php