note 97710 added to function.strtotime

From: Date: Tue, 04 May 2010 13:55:20 +0000
Subject: note 97710 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-168921@lists.php.net to get a copy of this message
To create the last day of the previous month (in PHP 5.2.10). For example: If today is 2010-03-15 and I want to get 2010-02-28! <?php // This will not make the correct date echo date("Y-m-d", strtotime("last day last month")); // 2010-02-14 // This trick will give this month's 0th day, namely prev month's last day echo date("Y-m-d", strtotime( (substr(date("Y-m-d"), 0, 7) . "-00") )); // 2010-02-28 ?> You can change to any other specified date: <?php echo date("Y-m-d", strtotime( (substr(date("Y-m-d", $timestamp), 0, 7) . "-00") )); ?> ---- Server IP: 92.43.200.200 Probable Submitter: 80.99.61.199 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/97710 Del: integrated -- https://master.php.net/note/delete/97710/integrated Del: useless -- https://master.php.net/note/delete/97710/useless Del: bad code -- https://master.php.net/note/delete/97710/bad+code Del: spam -- https://master.php.net/note/delete/97710/spam Del: non-english -- https://master.php.net/note/delete/97710/non-english Del: in docs -- https://master.php.net/note/delete/97710/in+docs Del: other reasons-- https://master.php.net/note/delete/97710 Reject -- https://master.php.net/note/reject/97710 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168921) next »