We have 91 guests online
PHP Scripts arrow Free PHP Tutorials arrow Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP 
Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP

Calculating time of sunrise / sunset for location with date_sunrise / date_sunset
User Rating: / 4
PoorBest 

Built-in function calculates the time of sunset and sunrise with latitude, longitude, zenith, and GMT offset. Added in PHP 5. (Credit: http://www.php.net/manual/en/function.date-sunset.php under ODL1.0)

  1. <?php
  2.  
  3. /* calculate the sunrise time for Lisbon, Portugal
  4. Latitude: 38.4 North
  5. Longitude: 9 West
  6. Zenith ~= 90
  7. offset: +1 GMT
  8. */
  9.  
  10. echo date("D M d Y"). ', sunrise time : ' .date_sunrise(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1);
  11.  
  12. ?>
  13.  
  14. outputs: Mon Dec 20 2004, sunrise time : 08:54
  15.  
  16. <?php
  17.  
  18. /* calculate the sunset time for Lisbon, Portugal
  19. Latitude: 38.4 North
  20. Longitude: 9 West
  21. Zenith ~= 90
  22. offset: +1 GMT
  23. */
  24.  
  25. echo date("D M d Y"). ', sunset time : ' .date_sunset(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1);
  26.  
  27. ?>
  28.  
  29. outputs: Mon Dec 20 2004, sunset time : 18:13

 

 

Directory Stats

There are 1019 listing and 46 categories in our website

Change Language