php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #63415
Patch new-DateTime-getOffset-example revision 2012-11-01 23:46 UTC by mike at mikehoward dot com dot au

Patch new-DateTime-getOffset-example for Documentation problem Bug #63415

Patch version 2012-11-01 23:46 UTC

Return to Bug #63415 | Download this patch
Patch Revisions:

Developer: mike@mikehoward.com.au


// 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);
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 22:00:01 2026 UTC