|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-04-30 09:14 UTC] noam at i-com-it dot com
in the date function (http://www.php.net/manual/en/function.date.php) Example 3. date() and mktime() example $lastmonth = mktime (0,0,0,date("m")-1,date("d"),date("Y")); i use it in the 31.4 like this: $month= mktime (0,0,0,date("m")-2,date("d"),date("Y")); i got "march"; because february only have 28 days . i use: $month= mktime (0,0,0,date("m")-2,1,date("Y")); instead; noam PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 07:00:01 2026 UTC |
It's not a bug. We want to get the date of the last month with the same day. If we put 1, the timestamp will be wrong, but yes, february has got only 28 days so you would need some verifications in your script to see if(date('m') == 02 && date('d') > 28) ... In the manual we will not make too complex scripts.