PHP Classes

PHP Day Light Calculator: Calculate the day hours for a given location

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 185 All time: 8,657 This week: 206Up
Version License PHP version Categories
day-light 1.0.0Freeware5PHP 5, Time and Date, Geography
Description 

Author

This class can calculate the day hours for a given location.

It can take the latitude and longitude of a location and the time zone and it can calculate several types of time values. Currently it can return:

- The current time of the day
- The Sunrise and Sunset time
- The duration of the period with Sun light
- The remaining number of Sun light left for the day
- The duration of the period without Sun light
- The remaining number without Sun light left for the day
- Data for an image that can be the Sun or Moon images depending whether it is day or night

In Spanish:

Esta clase calcula las horas de luz y de obscuridad del dia asi como las horas de puesta y salida del sol pasando como parámetro las coordenadas geograficas y el uso horario(timezone). Tambien muestra una imagen con el sol o la luna si es de dia o de noche.

Innovation Award
PHP Programming Innovation award nominee
January 2020
Number 4
Many activities can only happen during the period of the day when there is light coming from the Sun. An example of that kind of activity can be for instance going to a beach to receive sunlight baths.

This class can calculate the number of hours of sunlight for a given location.

This way, users of a PHP application that uses this class may be aware of the length of the period of the day that they can use to benefit from the Sun Light.

Manuel Lemos
Picture of Dannel
  Performance   Level  
Name: Dannel <contact>
Classes: 9 packages by
Country: Cuba Cuba
Innovation award
Innovation award
Nominee: 5x

Example

<?php
include 'php_light_time_calculator.php';
$obj=new LightnShade;
$a=$obj->dayLight(22.9666666666667,-82.15,"America/New_York");
?>
<?=
'Current time: '.$a['now']?> <br>
<?='Sunrise today: '.$a['sunrise']?> <br>
<?='Sunset today: '.$a['sunset']?> <br>
<?='Hours of Light: '.$a['lightHours']?> <br>
<?='Remaining Hours of Light : '.$a['lightHoursLeft']?> <br>
<?='Hours of Dark: '.$a['darkHours']?> <br>
<?='Remaining Hours of Dark : '.$a['darkHoursLeft']?> <br>
<?='Star Above our heads: <br>'.$a['Star']?> <br>


  Files folder image Files (2)  
File Role Description
Accessible without login Plain text file example.php Example Example script
Plain text file php_light_time_calculator.php Class Class

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:185
This week:0
All time:8,657
This week:206Up