php - How to set a variable based on time/date -
how can set variable, $a, specific value based on day of week , time of day.
for example, in pseudocode:
mon 09.00h - 16.59h, $a = 5, sat 12.00h - 13.00h, $a = 10
$time = time()%86400; $date = date("d"); // since 9 hours = 32400 seconds , 16 hours , 59 minutes = 61140 seconds if($date == "mon" && $time >= 32400 && $time <= 61140){ $a = 5; } // since 12 hours = 43200 seconds , 13 hours = 46800 seconds else if($date == "sat" && $time >= 43200 && $time <= 46800){ $a = 10; }
Comments
Post a Comment