Jump to content

How to write an IF statement for a period of time?


etrader

Recommended Posts

use unix times (seconds passed since 1st Jan 1970) and then just work with numbers, the strtotime() function is very useful...

i.e.

//current time
$time = time();

$min = strtotime("6:00pm");
$max strtotime("6:30pm");

if ($time >= $min && $time <= $max) {
echo 'time is between';
} else {
echo 'not between';
}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.