php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40744 possible mktime bug?
Submitted: 2007-03-07 06:25 UTC Modified: 2007-03-07 07:39 UTC
From: jeffkoston22 at yahoo dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.1 OS: Slackware 11
Private report: No CVE-ID: None
 [2007-03-07 06:25 UTC] jeffkoston22 at yahoo dot com
Description:
------------
I'm not really fond of mktime() but I needed a way of taking two dates in MySQL format and seeing which date is older... ie:

$date = "2007-03-01";
if ($date <= date('Y-m-d'))
{
  print "Expired";
} else {
  print "Not Expired";
}

I know you can't use dates like that in the condition so I used date('U') and mktime() to give me the seconds since the Unix Epoch but I decided to test using different date formats first just to see how mktime handles months and years that might or might not have leading zero's.. notice the difference in seconds with the year 08 vs. 07

please correct me if I'm doing something stupid here that I should not be doing. 

I don't quite understand Bug #25050 - is this the same situation?
 
thanks for your time!

Reproduce code:
---------------
print "test1: " . date('U', mktime(0, 0, 0,  3, 1, 2008)) . "<br />";   // 3-1-2008  returned 1204261200
print "test2: " . date('U', mktime(0, 0, 0,  3, 1,   08)) . "<br />";   // 3-1-08    returned 951800400
print "test3: " . date('U', mktime(0, 0, 0, 03, 1, 2008)) . "<br />";   // 03-1-2008 returned 1204261200
print "test4: " . date('U', mktime(0, 0, 0, 03, 1,   08)) . "<br />";   // 03-1-08   returned 951800400

print "test5: " . date('U', mktime(0, 0, 0,  3, 1, 2007)) . "<br />";   // 3-1-2007  returned 1172638800
print "test6: " . date('U', mktime(0, 0, 0,  3, 1,   07)) . "<br />";   // 3-1-07    returned 1172638800
print "test7: " . date('U', mktime(0, 0, 0, 03, 1, 2007)) . "<br />";   // 03-1-2007 returned 1172638800
print "test8: " . date('U', mktime(0, 0, 0, 03, 1,   07)) . "<br />";   // 03-1-07   returned 1172638800

test1: 1204347600
test2: 951886800
test3: 1204347600
test4: 951886800

test5: 1172725200
test6: 1172725200
test7: 1172725200
test8: 1172725200


Expected result:
----------------
I expected to see:
test1: 1204347600
test2: 1204347600
test3: 1204347600
test4: 1204347600

test5: 1172725200
test6: 1172725200
test7: 1172725200
test8: 1172725200


Actual result:
--------------
instead I got:
test1: 1204347600
test2: 951886800
test3: 1204347600
test4: 951886800

test5: 1172725200
test6: 1172725200
test7: 1172725200
test8: 1172725200


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-07 07:39 UTC] tony2001@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.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

01..08 are octal numbers.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 10 23:00:01 2025 UTC