FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Cant get accurate sunrise/sunset time





fladry
I use the following code to calculate the sunrise and sunset time of my place(kathmandu, Nepal)
Code:

<?php
date_default_timezone_set ("Asia/Kathmandu");
$lat=27.7;
$long=85.3667;
$offset=5.75;
$zenith=90.5;
$TimeStamp= date_sunrise(time(),SUNFUNCS_RET_TIMESTAMP,$lat,$long,$zenith,$offset);
echo 'Sunrise '.date("g:i a",$TimeStamp).'<br>';
$TimeStamp= date_sunset(time(),SUNFUNCS_RET_TIMESTAMP,$lat,$long,$zenith,$offset);
echo 'Sunset '.date("g:i a",$TimeStamp).'<br>';
?>


But the time doesnot match(by few minutes every day) to the time specified in other websites(like http://www.timeanddate.com/worldclock/astronomy.html?n=117 ). Can anyone help me in this please.
Fire Boar
It looks like your longitude/latitude/zenith may be more exact than that used by the website linked. The important thing is, does your script produce a time corresponding to the actual sunrise/sunset?
ogah
try add +(60*x) or -(60*x) behind time() and date() , x is number to adjust minutes
fladry
I tried adjusting the latitude and longitude. But it doesn't work for all days. The zenith is always 90.5. In the days of this month, the sun set time is one minute less than the actual sunset time. I added one minute to the sunset time and again the time just doesn't match for other months. The longitude and latitude i used here are the standard ones. I wonder what the websites use. But all of their time match( i just compared the time between 4/5 websites) except mine Sad
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.