WPDKDateTime::timeInRange PHP Method

timeInRange() public static method

Return TRUE if now time() is between $start and $expry.
Since: 1.5.16
public static timeInRange ( integer $start, integer $expiry ) : boolean
$start integer Start date.
$expiry integer Expiry date.
return boolean
    public static function timeInRange($start, $expiry)
    {
        // Check empty
        if (empty($start) && empty($expiry)) {
            return false;
        }
        // Get now
        $now = time();
        // Default
        $start = empty($start) ? $now : $start;
        $expiry = empty($expiry) ? $now : $expiry;
        // Stability
        if (!is_numeric($start) || !is_numeric($expiry)) {
            return false;
        }
        // Wrong range
        if ($start > $expiry) {
            return false;
        }
        return $start <= $now && $expiry >= $now;
    }