php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #23428 a Example 3. date() and mktime() example , bug
Submitted: 2003-04-30 09:14 UTC Modified: 2003-05-01 15:18 UTC
From: noam at i-com-it dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.1 OS: redhat 7.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: noam at i-com-it dot com
New email:
PHP Version: OS:

 

 [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
 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-01 15:18 UTC] nicos@php.net
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.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 08:00:01 2026 UTC