<?php/* 计算葡萄牙里斯本的日出时间 Latitude: 北纬 38.4 度 Longitude: 西经 9 度 Zenith ~= 90 offset: +1 GMT */echo date("D M d Y"). ', sunrise time : ' .date_sunrise(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1);?> ----------------------------------------------------------------------------- Just for those that are as stupid as me for the settings in php.ini and sunrise/sunset after googling for a while if found this info;`Zenith' is the angle that the centre of the Sun makes to a line perpendicular to the Earth's surface. ; ; The best Overall figure for zenith is 90+(50/60) degrees for true sunrise/sunset ; Civil twilight 96 degrees - Conventionally used to signify twilight ; Nautical twilight 102 degrees - the point at which the horizon stops being visible at sea. ; Astronical twilight at 108 degrees - the point when Sun stops being a source of any illumination. ; ;date.sunrise_zenith = 90.583333 85.4 ;date.sunset_zenith = 90.583333 85.4 --------------------------------------------------------- After some searching, I finally found a website that can calculate the sun's zenith. Just look up your city's lat/long (remember, west/south are negative even if it doesn't show where you look up the lat/long) and the time of sunrise/sunset and use this site:http://solardat.uoregon.edu/cgi-bin/SolarPositionCalculator.cgiYou have to enter in the sunrise/sunset times separately, but it works. San Diego is: Lat: 32.73 Long: -117.17 Sunrise Z.: 90.7379 Sunset Z.: 90.8880 ----------------------------------------------------------------------- 90是个大约角度,精确计算要用上面两个英文说明,或参考那个网址 1是时区,ini设置了时区的话,这个应该省略
echo(date_sunrise(time(), SUNFUNCS_RET_STRING, 39.9, 116.3));但是这么写就又不对了
echo(date_sunrise(time(), SUNFUNCS_RET_STRING, 39.9, 116.3, 90, 1));后边两个参数用的不太会,能解释下吗?
Latitude: 北纬 38.4 度
Longitude: 西经 9 度
Zenith ~= 90
offset: +1 GMT
*/echo date("D M d Y"). ', sunrise time : ' .date_sunrise(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1);?>
-----------------------------------------------------------------------------
Just for those that are as stupid as me
for the settings in php.ini and sunrise/sunset after googling for a while if found this info;`Zenith' is the angle that the centre of the Sun makes to a line perpendicular to the Earth's surface.
;
; The best Overall figure for zenith is 90+(50/60) degrees for true sunrise/sunset
; Civil twilight 96 degrees - Conventionally used to signify twilight
; Nautical twilight 102 degrees - the point at which the horizon stops being visible at sea.
; Astronical twilight at 108 degrees - the point when Sun stops being a source of any illumination.
;
;date.sunrise_zenith = 90.583333 85.4
;date.sunset_zenith = 90.583333 85.4
---------------------------------------------------------
After some searching, I finally found a website that can calculate the sun's zenith. Just look up your city's lat/long (remember, west/south are negative even if it doesn't show where you look up the lat/long) and the time of sunrise/sunset and use this site:http://solardat.uoregon.edu/cgi-bin/SolarPositionCalculator.cgiYou have to enter in the sunrise/sunset times separately, but it works.
San Diego is:
Lat: 32.73
Long: -117.17
Sunrise Z.: 90.7379
Sunset Z.: 90.8880
-----------------------------------------------------------------------
90是个大约角度,精确计算要用上面两个英文说明,或参考那个网址
1是时区,ini设置了时区的话,这个应该省略
PHP Date / Time 函数
定义和用法
date_sunrise() 函数返回指定的日期与地点的日出时间。语法
date_sunrise(timestamp,format,latitude,longitude,zenith,gmt_offset)参数 描述
timestamp 必需。
format 可选。规定如何返回结果:SUNFUNCS_RET_STRING (以 string 格式返回结果,比如 16:46)
SUNFUNCS_RET_DOUBLE (以 float 格式返回结果,比如 16.78243132)
SUNFUNCS_RET_TIMESTAMP (以 integer 格式(时间戳)返回结果,比如 1095034606)
latitude 可选。规定地点的纬度。默认是指北纬。因此如果要指定南纬,必须传递一个负值。
longitude 可选。规定地点的经度。默认是指东经。因此如果要指定西经,必须传递一个负值。
zenith 可选。
gmt_offset 可选。规定 GMT 与本地时间的差值。单位是小时。
例子
<?php
//计算葡萄牙里斯本的日出时间
//Latitude: 北纬 38.4 度
//Longitude: 西经 9 度
//Zenith ~= 90
//offset: +1 GMT
echo("Date: " . date("D M d Y") . "<br />");
echo("Sunrise time: ");
echo(date_sunrise(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?>输出:Date: Tue Jan 24 2006
Sunrise time: 08:52