Home Tutorial Php Phpdate date_sunrise

 
 

date_sunrise
Posted on: August 26, 2009 at 12:00 AM
Here, you will learn to access the sunrise time from date_sunrise function in PHP. This below example shows how to using the date_sunrise() in PHP.

 

date_sunrise

date_sunrise function returns time of sunrise for a given day and location. 

Description on PHP Date Sunrise Function

mixed date_sunrise ( int $timestamp [, int $format= SUNFUNCS_RET_STRING [, float $latitude= ini_get("date.default_latitude") [, float $longitude= ini_get("date.default_longitude") [, float $zenith= ini_get("date.sunrise_zenith") [, float $gmt_offset= 0 ]]]]] )

Parameter of date_sunsunrise() Format in PHP

timestamp - The timestamp of the day from which the sunrise time is taken.

format - the form of format are given below: 
SUNFUNCS_RET_STRING returns the result as string 14:22
SUNFUNCS_RET_DOUBLE returns the result as float 11.43213287
SUNFUNCS_RET_TIMESTAMP returns the result as integer (timestamp) 36040590

latitude - Defaults to North, pass in a negative value for South. See also: date.default_latitude

longitude - Defaults to East, pass in a negative value for West. See also: date.default_longitude

zenith - Default: date.sunrise_zenith

gmtoffset - Specified in hours

<?php
date_default_timezone_set('Europe/London');

$datetime = date_create('2008-08-03 14:52:10');
echo date_format($datetime, 'jS, F Y') . "\n";
echo date_format($datetime, DATE_ATOM);
?>

Find Example of date_sunsunrise() Format PHP:

date_default_timezone_set('India/Delhi');

$datetime = date_create('2009-08-25 14:52:10');
echo date_format($datetime, 'jS, F Y') . "\n";
echo date_format($datetime, DATE_ATOM);
?>

Latitude: 28.61 North
Longitude: 77.23 East
Zenith ~= 90
offset: +5.50 GMT
*/

echo date("D M d Y"). ', sunrise time : ' .date_sunrise(time(), SUNFUNCS_RET_STRING, 28.61, 77.23, 90, 5.50);

?>

The above example will output something similar to:

Tue Aug 25 2009, sunrise time : 06:04

Related Tags for date_sunrise:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.