Doc #63415 [NEW]: Code example incorrect
| From: | mike at mikehoward dot com dot au | Date: | Thu, 01 Nov 2012 23:45:17 +0000 |
| Subject: | Doc #63415 [NEW]: Code example incorrect | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-9041@lists.php.net to get a copy of this message | ||
From: mike at mikehoward dot com dot au
Operating system: not relevant
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Code example incorrect
Description:
------------
---
From manual page: http://www.php.net/datetimezone.getoffset#refsect1-
datetimezone.getoffset-examples
---
The example for getOffset says:
// Calculate the GMT offset for the date/time contained in the
$dateTimeTaipei
// object, but using the timezone rules as defined for Tokyo
// ($dateTimeZoneJapan).
$timeOffset = $dateTimeZoneJapan->getOffset($dateTimeTaipei);
This is not correct. You can't pass a DateTime object when used this way.
Test script:
---------------
// This is not a test script - this is a suggestion to replace the current
example
// Create a timezone object
$dateTimeZoneSyd = new DateTimeZone("Australia/Sydney");
// Create a DateTime object (it's daylight savings time now - 2012-11-02)
$dateTimeSydney = new DateTime("now", $dateTimeZoneSyd);
// Calculate the GMT offset for the date/time contained in the object
$timeOffset = $dateTimeSydney->getOffset();
// Should show int(39600).
var_dump($timeOffset);
--
Edit bug report at https://bugs.php.net/bug.php?id=63415&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63415&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63415&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63415&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63415&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63415&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63415&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63415&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63415&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63415&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63415&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63415&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63415&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63415&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63415&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63415&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63415&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63415&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63415&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63415&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63415&r=mysqlcfg