|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-11-10 23:40 UTC] it at ezy2c dot com
Description: ------------ Hi I have noticed that when i use zero date in windows it converts to the expected 1970 date however on our Centos 5 Server it fails. See live script http://amo2.flsecure.com/testdate.php Test script: --------------- EXAMPLE CODE: $zerodate="0000-00-00 00:00:00"; $convertdate=date("Y-m-d H:i:s",strtotime(0000-00-00 00:00:00)); echo("ORIG: ".$zerodate." | CONVERTED: ".$convertdate."); RESULT: ORIG: 0000-00-00 00:00:00 | CONVERTED: -0001-11-30 00:00:00 On MY WINDOWS BOX: ORIG: 0000-00-00 00:00:00 | CONVERTED: 1970-01-01 10:00:00 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 02:00:01 2025 UTC |
When I strtotime("0000-00-00 00:00:00") in the Linux Box I get -62170020000, when I do it on the windows box it returns NULL. Maybe this is the root of the issue, at least when it returns NULL it converts to 1970-01-01 10:00:00Perhaps there should be an option to return NULL. This isnt great when your dealing with MySQL databases that have date fields with 0000-00-00 00:00:00 format. At least when it returns null the date field interprets it as the 1970 date. This is an expedted date wince 1970 is the start of unix epoch. This Created variability over 32-bit and 64-bit systems and hence would need to adjust the code base to do something kind of work around (however some systems use lots of date values and this is VERY difficult to replace all the strtotime references) see below for a wrapper function. I feel that this logic SHOULD exist in 64 bit ONLY if the date is 0000-00-00 00:00:00, this way database default values can be handles easier and is cross compatible in both 64 or 32 bit systems. YOUR view maybe that is isnt a BUG, however its more of Incompatibility and Inconsistency across platforms and 32/64 bit systems. I would VERY much like you to consider changing this. function str2time($time) { if(strtotime($time)=="-62170020000") { return NULL; } else { return strtotime($time); } }