note 114706 added to function.mktime
| From: | Rad | Date: | Thu, 27 Mar 2014 05:31:36 +0000 |
| Subject: | note 114706 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199049@lists.php.net to get a copy of this message | ||
Be careful passing zeros into mktime, in most cases a zero will count as the previous unit of time.
The documentation explains this yet most of the comments here still use zeroes.
For example, if you pass the year 2013 into mktime, with zeroes for everything else, the outcome is
probably not what you are looking for.
<?php
echo date('F jS, Y g:i:s a', mktime(0, 0, 0, 0, 0, 2013));
// November 30th, 2012 12:00:00 am
?>
Instead of using 0's, try 1's. This makes more sense (except for minutes/seconds). Maybe
not as obvious of a purpose as zeroes to other programmers, though.
<?php
echo date('F jS, Y g:i:s a', mktime(1, 1, 1, 1, 1, 2013));
// January 1st, 2013 1:01:01 am
?>
----
Server IP: 192.41.45.150
Probable Submitter: 71.220.213.22
----
Manual Page -- http://php.net/manual/en/function.mktime.php
Edit -- https://master.php.net/note/edit/114706
Del: integrated -- https://master.php.net/note/delete/114706/integrated
Del: useless -- https://master.php.net/note/delete/114706/useless
Del: bad code -- https://master.php.net/note/delete/114706/bad+code
Del: spam -- https://master.php.net/note/delete/114706/spam
Del: non-english -- https://master.php.net/note/delete/114706/non-english
Del: in docs -- https://master.php.net/note/delete/114706/in+docs
Del: other reasons-- https://master.php.net/note/delete/114706
Reject -- https://master.php.net/note/reject/114706
Search -- https://master.php.net/manage/user-notes.php