Got these somewhere and any would suffice:
/////////////////////////
<?
$num = date('H');
if($num >= 1 && $num <= 6) {
$variable = between 1am & 6am;
} elseif($num >= 7 && $num <= 12) {
$variable = between 7am and midday;
} elseif($num >= 13 && $num <= 18) {
$variable = between 1pm and 6pm;
} else {
$variable = dodgy number, or between 7pm and midnight;
}
?>
///////////////////////
or
//////////////
<?
$switchvar = 0;
$hour = date('H');
if ($hour <= 16 and $hour >= 2) $switchvar = 50;
echo $switchvar;
?>
///////////////
or
/////////////
<?
$x = date("G");
if($x >= 2 && $x < 16) $tvar = 50;
else $tvar = 0;
?>
//////////////
or
///////////////
<?
// get the current time
$current_time=time();
echo $current_time;
// format time to current hour
// using "G" format for current hour 0-23
$current_hour=date("G",$current_time);
echo "<br>" . $current_hour;
// set variable based on hour
if($current_hour == 14 || $current_hour == 15) {
$var = 50;
echo "<br>" . $var;
}
?>
///////////////////////
Anyways, thanks everyone for the replies!
