[DOC-CVS] [doc-en] master: Set the timezone in the date_sun_info() example (#5740)
[email protected] (KentarouTakeda via GitHub)
| Newsgroups | php.doc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: KentarouTakeda (KentarouTakeda)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2026-08-07T13:36:52+01:00
Commit: https://github.com/php/doc-en/commit/aac47e05048c3371bfc46d65247d7bf1c4505bf3
Raw diff: https://github.com/php/doc-en/commit/aac47e05048c3371bfc46d65247d7bf1c4505bf3.diff
Set the timezone in the date_sun_info() example (#5740)
The example formats timestamps with date(), so its output followed the
timezone of whoever ran it and could not be pinned down: the recorded
values match no timezone on any PHP version I could test. The
coordinates are Jerusalem, so the times are reported in that zone, as
the polar night example below already does for Prudhoe Bay.
Changed paths:
M reference/datetime/functions/date-sun-info.xml
Diff:
diff --git a/reference/datetime/functions/date-sun-info.xml b/reference/datetime/functions/date-sun-info.xml
index d7fada248ca6..fed2c2406ef3 100644
--- a/reference/datetime/functions/date-sun-info.xml
+++ b/reference/datetime/functions/date-sun-info.xml
@@ -175,6 +175,7 @@
<programlisting role="php">
<![CDATA[
<?php
+date_default_timezone_set('Asia/Jerusalem');
$sun_info = date_sun_info(strtotime("2006-12-12"), 31.7667, 35.2333);
foreach ($sun_info as $key => $val) {
echo "$key: " . date("H:i:s", $val) . "\n";
@@ -184,15 +185,15 @@ foreach ($sun_info as $key => $val) {
&example.outputs;
<screen>
<![CDATA[
-sunrise: 05:52:11
-sunset: 15:41:21
-transit: 10:46:46
-civil_twilight_begin: 05:24:08
-civil_twilight_end: 16:09:24
-nautical_twilight_begin: 04:52:25
-nautical_twilight_end: 16:41:06
-astronomical_twilight_begin: 04:21:32
-astronomical_twilight_end: 17:12:00
+sunrise: 06:29:21
+sunset: 16:36:00
+transit: 11:32:41
+civil_twilight_begin: 06:02:36
+civil_twilight_end: 17:02:45
+nautical_twilight_begin: 05:32:14
+nautical_twilight_end: 17:33:08
+astronomical_twilight_begin: 05:02:31
+astronomical_twilight_end: 18:02:51
]]>
</screen>
</example>