php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47382 DateTime::getOffset documentation unclear
Submitted: 2009-02-13 15:16 UTC Modified: 2009-11-20 10:02 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: antti dot salminen at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2009-02-13 15:16 UTC] antti dot salminen at gmail dot com
Description:
------------
DateTime::getOffset is said to return the DST offset in the documentation. This sounds like it will simply return 0 or 3600 depending on whether or not DST is in effect for the given DateTime object. It actually returns the full offset from GMT. Documentation should better reflect this or the function be changed.

Reproduce code:
---------------
date_default_timezone_set('Europe/Helsinki');

$winter = new DateTime('2009-02-13 14:25:41');

echo $winter->getOffset();

Expected result:
----------------
0

Actual result:
--------------
7200

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-13 15:35 UTC] derick@php.net
Almost, it returns the full offset from *UTC*, and not *GMT*. They're slightly different: http://derickrethans.nl/leap_seconds_and_what_to_do_with_them.php
 [2009-11-20 10:02 UTC] vrana@php.net
Same as bug #49773.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Jun 16 20:00:02 2026 UTC