note 127162 added to function.strtotime

From: Date: Wed, 08 Jun 2022 19:54:44 +0000
Subject: note 127162 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-218570@lists.php.net to get a copy of this message
For those still using php versions < 8.0.0, it may help to know that explicitly supplying the 2nd argument $baseTime as NULL does *not* have the same effect as omitting it. <?php function adjustedTime($adjustment, $baseTime = null) { echo date('Y-m-d H:i:s', strtotime($adjustment, $baseTime)); } adjustTime('+1 day'); //1970-01-02 01:00:00 ?> Supplying NULL is equivalent to supplying int(0). So if you wrap strtotime() in this manner with a nullable $baseTime, make sure in your code to inspect $baseTime and supply time() instead of NULL, or call strtotime() without it in that case. ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.12.131 (proxied: 87.75.113.64) ---- Manual Page -- https://php.net/manual/en/function.strtotime.php Edit -- https://main.php.net/note/edit/127162 Del: integrated -- https://main.php.net/note/delete/127162/integrated Del: useless -- https://main.php.net/note/delete/127162/useless Del: bad code -- https://main.php.net/note/delete/127162/bad+code Del: spam -- https://main.php.net/note/delete/127162/spam Del: non-english -- https://main.php.net/note/delete/127162/non-english Del: in docs -- https://main.php.net/note/delete/127162/in+docs Del: other reasons-- https://main.php.net/note/delete/127162 Reject -- https://main.php.net/note/reject/127162 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218570) next »