website script?
Discussion
Is there such a script that can do this? Basically all i want to do is serve a certain webpage at certain times of the day, at other times a different webpage would be served, the URL that points to these pages would remain the same though? The script would need to get the time of day from the server. Any ideas?
crb said:
<?php
date_default_timezone_set('Europe/London');
$inc_file = "";
$minsnow = (date('G')*60)+(date('i'));
switch ($minsnow) {
case ($minsnow < 720):
$inc_file = "morning.html";
break;
case ($minsnow >= 720 && $minsnow < 990):
$inc_file = "afternoon.html";
break;
case ($minsnow >= 990):
$inc_file = "evening.html";
break;
}
require_once($inc_file);
?>
That'll work, basically save this code in the in a file named whatever.php then set up your 3 different html files (morning.html, afternoon.html and evening.html) the url you always link to will always be whatever.php
The first line sets the timezone to the uk and wouldn't be needed if your server is in the UK (mine isn't), but if someone is visiting from abroad it will be off, if this is an issue, I could probably find away round it.
Works a treat m8 Many thanks for your help.date_default_timezone_set('Europe/London');
$inc_file = "";
$minsnow = (date('G')*60)+(date('i'));
switch ($minsnow) {
case ($minsnow < 720):
$inc_file = "morning.html";
break;
case ($minsnow >= 720 && $minsnow < 990):
$inc_file = "afternoon.html";
break;
case ($minsnow >= 990):
$inc_file = "evening.html";
break;
}
require_once($inc_file);
?>
That'll work, basically save this code in the in a file named whatever.php then set up your 3 different html files (morning.html, afternoon.html and evening.html) the url you always link to will always be whatever.php
The first line sets the timezone to the uk and wouldn't be needed if your server is in the UK (mine isn't), but if someone is visiting from abroad it will be off, if this is an issue, I could probably find away round it.
Edited by crb on Friday 23 October 13:05
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff