#44399 [Fbk->Opn]: date (PHP 5) does not support O, but it's missing in the documentation

From: Date: Mon, 10 Mar 2008 21:01:33 +0000
Subject: #44399 [Fbk->Opn]: date (PHP 5) does not support O, but it's missing in the documentation
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-591@lists.php.net to get a copy of this message
ID: 44399 User updated by: robertbienert at gmx dot net Reported By: robertbienert at gmx dot net -Status: Feedback +Status: Open Bug Type: Documentation problem Operating System: all PHP Version: Irrelevant New Comment: Well, my error handler caught a E_COMPAT when using date('O') on PHP 5. The message told be to use the TZ environment variable or code like I presented. Previous Comments: ------------------------------------------------------------------------ [2008-03-10 20:41:12] danbrown@php.net Tested this on 5.0.4 and 5.2.4 and receive the expected result. ------------------------------------------------------------------------ [2008-03-10 20:32:26] robertbienert at gmx dot net Description: ------------ As of PHP 5, the date() function does not support 'O' anymore. Instead you have got to hack around with DateTime and Timezone objects (that seem to be undocumented, though), but there is nothing about it in the documentation, and PHP 5 is already some years old. Reproduce code: --------------- My current hack (written as comment to the date functions manual) follows: $dt = new DateTime(); $tz = $dt->getTimezone(); $hours = sprintf('%02d', (int)$tz->getOffset($dt) / 3600); $mins = sprintf('%02d', $tz->getOffset($dt) % 3600); $sign = $tz->getOffset($dt) > 0 ? '+' : '-'; echo $sign, $hours, $mins; Expected result: ---------------- The code above works as expected, but I would also expect that the date() manual tells me, that 'O' does not work anymore on PHP 5, why it does not work _and_ what the new way is. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44399&edit=1

« previous php.doc.bugs (#591) next »