From f8f64b7216ce7edd0056c3ee3ccd06db3aef6e61 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Mon, 26 Nov 2012 02:54:01 +0000 Subject: [PATCH] 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). git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328495 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/calendar/functions/easter-date.xml | 50 ++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/reference/calendar/functions/easter-date.xml b/reference/calendar/functions/easter-date.xml index d4e0b45155..e4ab52eff5 100644 --- a/reference/calendar/functions/easter-date.xml +++ b/reference/calendar/functions/easter-date.xml @@ -107,6 +107,56 @@ echo date("M-d-Y", easter_date(2001)); // Apr-15-2001 + + &reftitle.notes; + + + easter_date relies on your system's C library time + functions, rather than using PHP's internal date and time functions. As a + consequence, easter_date uses the + TZ environment variable to determine the time zone it + should operate in, rather than using PHP's + default time zone, which may + result in unexpected behaviour when using this function in conjunction + with other date functions in PHP. + + + As a workaround, you can use the easter_days with + DateTime and DateInterval to + calculate the start of Easter in your PHP time zone as follows: + + + +add(new DateInterval("P{$days}D")); +} + +foreach (range(2012, 2015) as $year) { + printf("Easter in %d is on %s\n", + $year, + get_easter_datetime($year)->format('F j')); +} +?> +]]> + + &example.outputs; + + + + + + + &reftitle.seealso;