Speed up development with full-stack environments for every branch.

Learn More

Get the sunrise time using date_sunrise() function [PHP]

112 Runs 447 Views 121 Copies
Saved

Saved

sundip 66

sundip
published 4 years ago

<?php

/**
 * Calculate the time of sunrise for a given day and location using date_sunrise()
 * Sunrise time for De Bilt, The Netherlands, weather station #06260
 * 
 */
//latitude
$lat = 52.10;    // North
//longitude
$long = 5.18;    // East
//GMT offset
$offset = 1;    // difference between GMT and local time in hours
//sun's zenith
$zenith = 90 + 50 / 60;
//calculate the sunrise time, the param SUNFUNCS_RET_STRING specifies that time 
//should be returned as string
$sunriseTime = date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);

echo '<center>';
echo '<br /><div style="background-color:green;color:#fff;padding:10px;width:600px;font-size:16px">
<b>Sunrise time for De Bilt, The Netherlands, weather station #06260, 
<br />is: ' . $sunriseTime . ' on ' . date('D M d Y') . '</b>
</div><br />';
echo '</center>';
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).