Ask a Question related to PHP Bugs, Design and Development.
-
jeffkoston22 at yahoo dot com #1
#40744 [NEW]: possible mktime bug?
From: jeffkoston22 at yahoo dot com
Operating system: Slackware 11
PHP version: 5.2.1
PHP Bug Type: Date/time related
Bug description: possible mktime bug?
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
--
Edit bug report at [url]http://bugs.php.net/?id=40744&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40744&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40744&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40744&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40744&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40744&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40744&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40744&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40744&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40744&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40744&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40744&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40744&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40744&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40744&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40744&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40744&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40744&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40744&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40744&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40744&r=mysqlcfg[/url]
jeffkoston22 at yahoo dot com Guest
-
bad mktime return
mktime returns bad values for dates before 1-1-1970. I am using a Linux box (rh 9.0) so the the windows problem does not apply here. The code... -
mktime() adjustment
Is there a way to may a mktime() variable in a PHP script to adjust for a 4 hour difference between server time and my time? When it's 1:00 pm my... -
mktime help - Jan, Feb......
PHP doesn't have ENUM and I'm inputting the date 14-SEP-2003 and I want to "insert into atable values ('2003-09-14', .........==> mysql. Anybody... -
mktime <=> localtime
I have some trouble with time conversion. Initially a have an utc time in a broken down struct. It is given as day, month, year, hour, min and... -
localtime/mktime = gmtime/???
I am looking forward to find a pendant for gmtime. While localtime converts the unix internal time_t time (seconds since epoche) into a broken down... -
tony2001@php.net #2
#40744 [Opn->Bgs]: possible mktime bug?
ID: 40744
Updated by: [email]tony2001@php.net[/email]
Reported By: jeffkoston22 at yahoo dot com
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: Slackware 11
PHP Version: 5.2.1
New Comment:
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 [url]http://www.php.net/support.php[/url] 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.
Previous Comments:
------------------------------------------------------------------------
[2007-03-07 06:25:37] 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
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40744&edit=1[/url]
tony2001@php.net Guest



Reply With Quote

