I would like to know if its possible to make script that will work only limited time. For example I have poll on my web page but like to make it active only, for example, from 8:00 till 18:00.
Php time
Started by Latinoking, Sep 03 2007 02:25 PM
6 replies to this topic
#1
Posted 03 September 2007 - 02:25 PM
#2
Posted 03 September 2007 - 02:35 PM
Sure! You should look into one of my tutorials. The time calculation uses everything you need for your script.
#3
Posted 03 September 2007 - 02:39 PM
Should work. Haven't tested this but try:
In theory that should work. Someone'll correct me if I'm wrong. I would test it but Dreamweavers playing up for me and I don't like using notepad.
<?php
$time = time('h'); //not sure about this bit, haven't used time function in a LONG time
if($time > "8" || $time < "18") { // If this doesn't work, try taking the " out
// Your script here
}
else {
echo("Sorry! The script is offline");
}
In theory that should work. Someone'll correct me if I'm wrong. I would test it but Dreamweavers playing up for me and I don't like using notepad.
#4
Posted 03 September 2007 - 02:40 PM
yup ofcourse. e.g. a script that will work fo the next hour:
another way to get the time to stop could be strtotime("08:00:00 10 September 2000");
Anyway, you need a timestamp in that form
<?php
$current_time = time();
$time_to_stop = 1188859896
if($current_time < $time_to_stop){
//script goes here
}else{
print "Sorry, you've missed it";
}
?>
another way to get the time to stop could be strtotime("08:00:00 10 September 2000");
Anyway, you need a timestamp in that form
#6
Posted 04 September 2007 - 02:09 PM
And one more question about time. Is there way to make script that will auto load at particular time ?
#7
Posted 04 September 2007 - 03:28 PM
I believe a Cron Job would be needed for this... check your cPanel.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
