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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 17:01:28 2024 UTC