ID: 48092 Updated by: der...@php.net Reported By: kenny at tnsnurse dot com -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: Windows Server 2000 PHP Version: 5.2.9 New Comment:
Not understanding things doesn't make the logic bogus. For example, Unix timestamps (like the big fancy number that you posted) are always in UTC (seconds since 1970-01-01 00:00 UTC). In case you have a timezone selected, it might shift to/from DST during your "calculation" and it fucks up because you're doing it wrong. For me, the code you gave shows: $ php -r 'echo date("M j, Y H:i", (1237787999 - 86400));' Mar 22, 2009 06:59 which is perfectly okay. So two things: 1. Set the proper time zone 2. Use proper code like: <?php $d = date_create( "@1237787999" )->modify( "-1 day" ); echo $d->format( 'M j, Y H:i' ), "\n"; ?> 3. If you really want to know how all this stuff works: http://phpdatebook.com Previous Comments: ------------------------------------------------------------------------ [2009-05-14 13:38:27] kleeh at bellsouth dot net This is one of a number of reasons -- but the most important one -- that we cannot switch to PHP 5. Apparently this guy can't either, or he has and he's discovered the bug too late. Is there not a work-around for this in PHP 5 -- one that doesn't involve changing massive amounts of logic? You guys usually do a great job. This looks like it slipped through the cracks. ------------------------------------------------------------------------ [2009-04-27 22:20:24] kenny at tnsnurse dot com Description: ------------ We do not need PHP to "force" us into accepting its Daylight Savings Time calculations. Both our database and web boxes are set to Standard time and we never switch them to DST. We don't WANT PHP's DST logic screwing with our dates because we don't care about DST when we're posting, reading, echoing, or even doing date diffs. But I don't see any way in 5.2.9 to tell it to ignore DST -- you're even deprecating the one switch that seemed to work in PHP 4.3. So if you're going to do that, we need a switch or an ini file parameter to tell PHP to ignore DST. Reproduce code: --------------- date("M j, Y H:i", (1237787999 - 86400). Exact code is << echo ">Week #{$row->periodid} WE " . date("M j, Y H:i", ($row->enddate - 86400)) >>. I gave you the 1237787999 as an example of a date we're retrieving from mysql. Expected result: ---------------- I expect to see March 21, 2009 23:59:59, unless you've redefined the mathematical result of 24 * 60 * 60. Actual result: -------------- The actual, "echoed-to-the-screeen" result of this is March 22, 2009 00:59:59. In what universe is this correct? The "1237787999" is an example of a correct date on our mysql database (returned in a variable and echoed) and it is the unix timestamp representation of March 22, 2009 23:59:59. If I subtract 86400 (which USED to be 24 hours) from that, I should get March 21, 2009 23:59:59. This should be simple arithmetic; I should not have to put up with PHP's DST stuff in doing this. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48092&edit=1