php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20596 date function gives wrong result for format 't'
Submitted: 2002-11-23 09:30 UTC Modified: 2002-11-23 09:56 UTC
From: paul dot dodd at unibe dot ch Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.2.1 OS: WIN 2000
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: paul dot dodd at unibe dot ch
New email:
PHP Version: OS:

 

 [2002-11-23 09:30 UTC] paul dot dodd at unibe dot ch
<?php
// As September has 30 days $x, $y & $z should all be
// 30 ... instead the result is always 31
// Unfortunately cal_days_in_month is not supported on the
// target server (php 4.1.2) even though though the
// documentation says it is

$x = date('t', '1 Sep 2002');
$y = date('t', 'Sep');
$z = date('t', '2002-09-01');
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-23 09:53 UTC] michael dot mauch at gmx dot de
The second argument of date() should be an integer timestamp, not a string. You can use e.g. mktime() or strtotime() to get such a timestamp:

# php -r 'echo date("t", mktime(0,0,0,9,1,2002)),"\n";'
30
 [2002-11-23 09:56 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

right, not a bug -> bogus
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC