note 78031 deleted from function.date by ezyang
| From: | ezyang@php.net | Date: | Tue, 25 Sep 2007 02:14:34 +0000 |
| Subject: | note 78031 deleted from function.date by ezyang | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-130766@lists.php.net to get a copy of this message | ||
Note Submitter: weeblesue at aol dot com
Reason: useless
----
I needed to redirect a registration page based on time and date. I set the meeting date, and set the
cutoff to be 2 days prior to that, at 4 pm (i.e. meeting = Thursday, cutoff = Tuesday at 4 PM). I
needed to automatically redirect the page Tuesday at 4 pm (sorry you missed registration), then
again after the meeting was over (wait till next month). This is what I came up with. So far, it
works! Not bad for my first php script! Anyway, the pages I redirect the users to have script to
verify that it's valid - so they can't just enter the registration page URL and register
after the deadline.
<?php
$meeting_date = strtotime("September 27 2007"); //Change this line only
$cutoff = $meeting_date - 115200; //this takes us to 4 pm 2 days before
$now = time()-3600; //adjust from server time to my time - just one zone off
If ($now <= $cutoff)
header('Location: http://www.site.com/register.php');
else if
($now > $cutoff && $now < $meeting_date)
header('Location: http://www.site.com/Done.php');
else
header('Location: http://www.site.com/NotReady.php');
?>