note 70031 added to function.date-sunset

From: Date: Sat, 30 Sep 2006 12:17:50 +0000
Subject: note 70031 added to function.date-sunset
Groups: php.notes 
Request: Send a blank email to php-notes+get-117881@lists.php.net to get a copy of this message
I use an IP to location database to determine the visitor's approximate latitude and longitude and then serve them a day or night color scheme based on whether it is before civil dawn or dusk. I've had problems when not specifying the timezone, specifically a 1 hour error, so I use GMT. <? date_default_timezone_set("GMT"); function scheme() { $sunrise = date_sunrise(time(), SUNFUNCS_RET_DOUBLE, $latitude, $longitude, 96, 0); $sunset = date_sunset(time(), SUNFUNCS_RET_DOUBLE, $latitude, $longitude, 96, 0); $now = date("H") + date("i") / 60 + date("s") / 3600; if ($sunrise < $sunset) if (($now > $sunrise) && ($now < $sunset)) return "day"; else return "night"; else if (($now > $sunrise) || ($now < $sunset)) return "day"; else return "night"; } ?> ---- Server IP: 194.153.94.10 Probable Submitter: 86.108.85.74 ---- Manual Page -- http://www.php.net/manual/en/function.date-sunset.php Edit -- https://master.php.net/note/edit/70031 Del: integrated -- https://master.php.net/note/delete/70031/integrated Del: useless -- https://master.php.net/note/delete/70031/useless Del: bad code -- https://master.php.net/note/delete/70031/bad+code Del: spam -- https://master.php.net/note/delete/70031/spam Del: non-english -- https://master.php.net/note/delete/70031/non-english Del: in docs -- https://master.php.net/note/delete/70031/in+docs Del: other reasons-- https://master.php.net/note/delete/70031 Reject -- https://master.php.net/note/reject/70031 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117881) next »