note 78031 added to function.date

From: Date: Tue, 25 Sep 2007 02:03:42 +0000
Subject: note 78031 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-130765@lists.php.net to get a copy of this message
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'); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 98.198.168.77 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/78031 Del: integrated -- https://master.php.net/note/delete/78031/integrated Del: useless -- https://master.php.net/note/delete/78031/useless Del: bad code -- https://master.php.net/note/delete/78031/bad+code Del: spam -- https://master.php.net/note/delete/78031/spam Del: non-english -- https://master.php.net/note/delete/78031/non-english Del: in docs -- https://master.php.net/note/delete/78031/in+docs Del: other reasons-- https://master.php.net/note/delete/78031 Reject -- https://master.php.net/note/reject/78031 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130765) next »