3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Get an array of human readable times for sun events * @param \DateTime $date A \DateTime Object set to the desired date * and the correct timezone for the place in question * @param float $lat The latitude of the place in question * @param float $lon The longitude of the place in question * * @return array An associative array of human readable times sorted in chronological order. */ function adjustedSunInfo(\DateTime $date,$lat,$lon) { $sinfo=date_sun_info ($date->getTimestamp() ,$lat,$lon ); foreach($sinfo as $key=>$val) { //You should check that the value isn't 1 or empty first $time = new \DateTime('@' . $val); $time->setTimezone($date->getTimeZone()); $sinfo[$key] = $time->format('Y m d H:i:s'); } asort($sinfo); return $sinfo; } $time = new \DateTime('2013-01-01', new \DateTimeZone('Pacific/Chatham')); var_dump(adjustedSunInfo($time, -44.5, -176.2));
Output for git.master, git.master_jit, rfc.property-hooks
array(9) { ["astronomical_twilight_begin"]=> string(19) "2013 01 01 03:22:47" ["nautical_twilight_begin"]=> string(19) "2013 01 01 04:24:22" ["civil_twilight_begin"]=> string(19) "2013 01 01 05:12:25" ["sunrise"]=> string(19) "2013 01 01 05:47:08" ["transit"]=> string(19) "2013 01 01 13:33:13" ["sunset"]=> string(19) "2013 01 01 21:19:19" ["civil_twilight_end"]=> string(19) "2013 01 01 21:54:02" ["nautical_twilight_end"]=> string(19) "2013 01 01 22:42:05" ["astronomical_twilight_end"]=> string(19) "2013 01 01 23:43:40" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
51.61 ms | 402 KiB | 8 Q