php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13992 31st of month causes date function to 'skip'
Submitted: 2001-11-08 13:36 UTC Modified: 2001-11-08 13:49 UTC
From: john at londonriverside dot co dot uk Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.0.4 OS: HP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: john at londonriverside dot co dot uk
New email:
PHP Version: OS:

 

 [2001-11-08 13:36 UTC] john at londonriverside dot co dot uk
See my web page on 31st of a month and notice how the months and/or days repeat: eg January, January, March, March etc.  www.londonriverside.co.uk/datebug.php

This is the code on the server:

<html>
<head>
</head>
<body>
//Select FromDay
    print ("<select name=\"FromDay\">");
    for ($x=1; $x<=31; $x++)
    {
      if (sprintf("%02d", date(d, mktime(0,0,0,1,$x,date("Y")))) == date(d) AND !ISSET($FromDay))
      {
      echo "<option value=\"" . sprintf("%02d", date(d, mktime(0,0,0,1,$x,date("Y")))) .  "\" selected>" . date(d, mktime(0,0,0,1,$x,date("Y"))) . "</option>\n";
      }
      elseif (sprintf("%02d", date(d, mktime(0,0,0,1,$x,date("Y")))) <> $FromDay) 
      {
      echo "<option value=\"" . sprintf("%02d", date(d, mktime(0,0,0,1,$x,date("Y")))) .  "\">" . date(d , mktime(0,0,0,1,$x,date("Y"))) . "</option>\n";
      }
      else
      {
      echo "<option value=\"" . sprintf("%02d", date(d, mktime(0,0,0,1,$x,date("Y")))) .  "\" selected>" . date(d, mktime(0,0,0,1,$x,date("Y"))) . "</option>\n";
      }
    }
    print ("</select>");

//Select FromMonth
    print ("</td>\n<td width=50><font face=verdana size=2>Month</font></td>\n<td width=61>");
    print ("<select name=\"FromMonth\">");
    for ($x=1; $x<=12; $x++)
    {
      if (sprintf("%02d", date(m, mktime(0,0,0,$x,date("d"),date("Y")))) == date(m) AND !ISSET($FromMonth)) 
      {
      echo "<option value=\"" . sprintf("%02d", date(m, mktime(0,0,0,$x,date("d"),date("Y")))) .  "\" selected>" . date(M , mktime(0,0,0,$x,date("d"),date("Y"))) . "</option>\n";
      }
      elseif (sprintf("%02d", date(m, mktime(0,0,0,$x,date("d"),date("Y")))) <> $FromMonth) 
      {
      echo "<option value=\"" . sprintf("%02d", date(m, mktime(0,0,0,$x,date("d"),date("Y")))) .  "\">" . date(M, mktime(0,0,0,$x,date("d"),date("Y"))) . "</option>\n";
      }
      else
      {
      echo "<option value=\"" . sprintf("%02d", date(m, mktime(0,0,0,$x,date("d"),date("Y")))) .  "\" selected>" . date(M , mktime(0,0,0,$x,date("d"),date("Y"))) . "</option>\n";
      }
    }
    print ("</select>");
?>
</body>
</html>



Regards,

John

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-08 13:44 UTC] derick@php.net
I'm pretty sure this is not a bug, and your example URI didn't show anything. Please ask support questions on the php-general@lists.php.net mailinglist.

Derick
 [2001-11-08 13:49 UTC] cnewbill@php.net
This is not a bug.  mktime and date are doing exactly what you told them to...take an long int date and convert it into something human readable.  It is not skipping it is simply giving you the accurate date for what mktime returned based on your input.

-Chris

Bug along the same lines http://bugs.php.net/bug.php?id=13888
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC