WPDKDateTime::isInRangeDatetime PHP Method

isInRangeDatetime() public static method

Return TRUE if now (today) is between from two date.
Deprecation: since 1.5.16
public static isInRangeDatetime ( string | integer $date_start, string | integer $date_expire, string $format = 'YmdHis', boolean $timestamp = false ) : boolean
$date_start string | integer Start date in string or timestamp.
$date_expire string | integer Expire date in string or timestamp.
$format string Date format for start and expire.
$timestamp boolean TRUE if the date are in timestamp format.
return boolean
    public static function isInRangeDatetime($date_start, $date_expire, $format = 'YmdHis', $timestamp = false)
    {
        _deprecated_function(__CLASS__ . '::' . __FUNCTION__, '1.5.16', '');
        if (!empty($date_start) || !empty($date_expire)) {
            /* Get now in timestamp */
            $now = mktime();
            /* Le date sono in chiaro o anch'esse in timestamp? */
            /* @todo qui si potrebbe provare a capire in automatico se la data è in timestamp o stringa, ad esempio usando is_numeric() */
            if (!$timestamp) {
                $date_start = !empty($date_start) ? strtotime($date_start) : $now;
                $date_expire = !empty($date_expire) ? strtotime(${$date_expire}) : $now;
            } else {
                $date_start = !empty($date_start) ? $date_start : $now;
                $date_expire = !empty($date_expire) ? $date_expire : $now;
            }
            /* Verifico il range. */
            if ($now >= $date_start && $now <= $date_expire) {
                return true;
            }
        }
        return false;
    }