note 120096 added to function.mktime

From: Date: Fri, 28 Oct 2016 11:52:24 +0000
Subject: note 120096 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-206972@lists.php.net to get a copy of this message
What's odd is that mktime doesn't seem to support every possible year number. It's common sense that 2 digit (shortened) year numbers are interpreted in the range 1970..2069 However, when padded with zeroes, no such transformation should happen (at least that is the behaviour of other date functions). Unfortunately it does (until year 100 *inclusive*): <?php echo date("Y-m-d",mktime(0,0,0,1,1,"0001")); // Expected: 0001-01-01 // Result: 2001-01-01 INCORRECT echo date("Y-m-d",mktime(0,0,0,1,1,"0100")); // Expected: 0100-01-01 // Result: 2000-01-01 INCORRECT echo date("Y-m-d",mktime(0,0,0,1,1,"0101")); // Expected: 0101-01-01 // Result: 0101-01-01 Correct ?> ---- Server IP: 72.52.91.14 Probable Submitter: 37.153.219.193 ---- Manual Page -- http://php.net/manual/en/function.mktime.php Edit -- https://master.php.net/note/edit/120096 Del: integrated -- https://master.php.net/note/delete/120096/integrated Del: useless -- https://master.php.net/note/delete/120096/useless Del: bad code -- https://master.php.net/note/delete/120096/bad+code Del: spam -- https://master.php.net/note/delete/120096/spam Del: non-english -- https://master.php.net/note/delete/120096/non-english Del: in docs -- https://master.php.net/note/delete/120096/in+docs Del: other reasons-- https://master.php.net/note/delete/120096 Reject -- https://master.php.net/note/reject/120096 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206972) next »