All pastes #470658 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-04 12:36 UTC
rendered paste body
<?php
# Author Alex
$greenbrae_latitude = 37.948;
$greenbrae_longitude = -122.523;
$greenbrae_zenith = 90; 



date_default_timezone_set("Etc/GMT+7"); // You might adjust this.

$day = date("l");
$greenbrae_sunset = date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, $greenbrae_latitude, $greenbrae_longitude, $greenbrae_zenith, -7);


if($day == "Friday") {
$currently_time = (int)microtime(true);
$sunset_ms = $greenbrae_sunset;
  if($currently_time > $sunset_ms) {
   header("Location: where_to_locate_if_its_friday.php");
  }
}

if($day == "Saturday") {
$currently_time = (int)microtime(true);
$one_hour_in_ms = 3600000;
$sunset_ms = $greenbrae_sunset;

if($currently_time > $sunset_ms)  { // if its after sunset
 if(($sunset_ms+$one_hour_in_ms) < microtime()) {
   header("Location: where_to_locate_when_its_saturday");
   }
  }
}


?>
<br><br><br>
I need a PHP include file. When included in a page, this file will do the following:

1. Determine the day of week in California and the actual current time in California.

2. Determine the time of sunset in California (specific location will be provided)

3. If the day is Friday and the current actual time in California is after sunset, then redirect the user to a certain page.

4. If the day is Saturday and the current actual time in California is before one hour after sunset, then redirect the user to a certain page.

5. If the time is not either of the above, then do nothing whatsoever.
?>