<?php
# Author Alex 'easter' Stead
$greenbrae_latitude = 37.948; // latitude of greenbrae
$greenbrae_longitude = -122.523; // longitude of greenbrae
$greenbrae_zenith = 90; // zenith of greenbrae, wrong probably, couldnt find right one, you should know.
/*
We use +8 because the GMT in California is -8.
The /Etc/ has unfortionaly reversed values, i do GMT+2 it means GMT-2
and so on, this explains why ive setted here +8
*/
date_default_timezone_set("Etc/GMT+8");
$daylight_saving = date('I'); // returns true if its daylight saving time.
if($daylight_saving) {
date_default_timezone_set("Etc/GMT+7");
$tz = -7; // We need this because of sunset method!
}
$day = date("l"); // returns currently day in California
// returns sunset time in Greenbrae, returns milliseconds
$greenbrae_sunset = date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, $greenbrae_latitude, $greenbrae_longitude, $greenbrae_zenith);
if($day == "Friday") {
/*
If currently time() ( returned by milliseconds ) is bigger then greenbrae sunset
then it will locate you a where_to_locate_if_its_friday.php file.
*/
if(time() > $greenbrae_sunset) {
header("Location: where_to_locate_if_its_friday.php");
}
}
if($day == "Saturday") {
/*
Next code checks if current time is bigger then greenbrae sunset time.
*/
if(time() > $greenbrae_sunset) {
/*
Next code checks if its not bigger then
sunset_time+one_hour, if it isnt then it redirects
you to site where_to_locate_when_its_saturday.php
btw, knowing that 3600000 is one hour in milliseconds helps us :P
*/
if(($greenbrae_sunset()+3600000) < time()) {
header("Location: where_to_locate_when_its_saturday.php");
}
}
}
?>