mervpayne Posted December 7, 2012 Share Posted December 7, 2012 Hi, I have a new project on the go that requires a 'redirect.php' page to contain some code which checks the date and sends the user to a new page dependent on the date. All going well when I set up and tested yesterday, but ran into problems today. Here's a sample of the code: <?php $hour = date('G'); $minute = date('i'); $day = date('w'); $m = $hour * 60 + $minute; // Minutes since midnight. if(strtotime("2012/12/6") <= time()) { header("location: http://www.myurl.com/06122012.htm"); exit; } if(strtotime("2012/12/7") <= time()) { header("location: http://www.myurl.com/07122012.htm"); exit; } if(strtotime("2012/12/9") <= time()) { header("location: http://www.myurl.com/09122012.htm"); exit; } if(strtotime("2012/12/12") <= time()) { header("location: http://www.smyurl.com12122012.htm"); exit; } ?> Like I say it worked yesterday (6/12 - it went to the 06122012.htm page) but today, when I was expecting it to go to the 7/12 content, it didn't, iit still went to the 6/12 content. I can see why, (I tested it by removing the 6/12 bit of the script and of course it went to the 7/12 content) but I can't work out how to include a new piece of script that tells it 'if the date has passed go on to the next date check' I guess it's something simple, along the lines of checking what the actual current date is, but I can't figure it out, any help would be much appreciated! Thanks Link to comment https://forums.phpfreaks.com/topic/271720-help-required-for-a-date-sensitive-referal-php-script/ Share on other sites More sharing options...
Pikachu2000 Posted December 7, 2012 Share Posted December 7, 2012 To have a static html document for every day in the calendar completely defeats the purpose of using a dynamic language like PHP. It would be much more efficient to just load content based on the date than to redirect to a page with a file name that matches the date. Link to comment https://forums.phpfreaks.com/topic/271720-help-required-for-a-date-sensitive-referal-php-script/#findComment-1398139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.