Home Tutorial Php Phpdate date_sunrise

 
 

Share on Google+Share on Google+
date_sunrise
Posted on: August 26, 2009 at 12:00 AM
Advertisement
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

Advertisement

Related Tags for date_sunrise:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 26, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com