php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63597 easter_date ignores PHP's timezone and uses the TZ env variable
Submitted: 2012-11-25 15:13 UTC Modified: 2012-11-26 02:53 UTC
From: anon at anon dot anon Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.4.9 OS:
Private report: No CVE-ID: None
 [2012-11-25 15:13 UTC] anon at anon dot anon
Description:
------------
The easter_date function magics a random timezone out of the air, rendering it worthless.

Test script:
---------------
<?php

date_default_timezone_set('UTC');
for ($year = 1970; $year <= 2037; $year++) {
	echo gmdate('Y-M-d H:i:s', easter_date($year)) . "\n";
}


Actual result:
--------------
1970-Mar-29 00:00:00
1971-Apr-10 23:00:00
1972-Apr-01 23:00:00
1973-Apr-21 23:00:00
1974-Apr-13 23:00:00
1975-Mar-30 00:00:00
1976-Apr-17 23:00:00
1977-Apr-09 23:00:00
1978-Mar-26 00:00:00
1979-Apr-14 23:00:00
1980-Apr-05 23:00:00
1981-Apr-18 23:00:00
1982-Apr-10 23:00:00
1983-Apr-02 23:00:00
1984-Apr-21 23:00:00
1985-Apr-06 23:00:00
1986-Mar-30 00:00:00
1987-Apr-18 23:00:00
1988-Apr-02 23:00:00
1989-Mar-26 00:00:00
1990-Apr-14 23:00:00
1991-Mar-31 00:00:00
1992-Apr-18 23:00:00
1993-Apr-10 23:00:00
1994-Apr-02 23:00:00
1995-Apr-15 23:00:00
1996-Apr-06 23:00:00
1997-Mar-30 00:00:00
1998-Apr-11 23:00:00
1999-Apr-03 23:00:00
2000-Apr-22 23:00:00
2001-Apr-14 23:00:00
2002-Mar-31 00:00:00
2003-Apr-19 23:00:00
2004-Apr-10 23:00:00
2005-Mar-27 00:00:00
2006-Apr-15 23:00:00
2007-Apr-07 23:00:00
2008-Mar-23 00:00:00
2009-Apr-11 23:00:00
2010-Apr-03 23:00:00
2011-Apr-23 23:00:00
2012-Apr-07 23:00:00
2013-Mar-31 00:00:00
2014-Apr-19 23:00:00
2015-Apr-04 23:00:00
2016-Mar-27 00:00:00
2017-Apr-15 23:00:00
2018-Mar-31 23:00:00
2019-Apr-20 23:00:00
2020-Apr-11 23:00:00
2021-Apr-03 23:00:00
2022-Apr-16 23:00:00
2023-Apr-08 23:00:00
2024-Mar-31 00:00:00
2025-Apr-19 23:00:00
2026-Apr-04 23:00:00
2027-Mar-28 00:00:00
2028-Apr-15 23:00:00
2029-Mar-31 23:00:00
2030-Apr-20 23:00:00
2031-Apr-12 23:00:00
2032-Mar-28 00:00:00
2033-Apr-16 23:00:00
2034-Apr-08 23:00:00
2035-Mar-25 00:00:00
2036-Apr-12 23:00:00
2037-Apr-04 23:00:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-26 02:39 UTC] aharvey@php.net
-Summary: easter_date is fucking stupid +Summary: easter_date ignores PHP's timezone and uses the TZ env variable -Status: Open +Status: Assigned -Type: Bug +Type: Documentation Problem -Package: Date/time related +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2012-11-26 02:39 UTC] aharvey@php.net
Thanks for your well reasoned, not at all abusive bug report, anonymous.

Anyway, there is an actual issue here that isn't documented, which is that easter_date() uses the libc date handling functions, which means it's beholden to the TZ environment variable and not PHP's default time zone. There's a pretty simple workaround using easter_days() and DateTime::add(), so I'll get a note into the documentation to demonstrate that.
 [2012-11-26 02:53 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328495
Log: Add a note about the timezone gotcha in easter_date().

Fixes doc bug #63597 (easter_date ignores PHP's timezone and uses the TZ env
variable).
 [2012-11-26 02:53 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2012-11-26 02:53 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 16:01:36 2025 UTC