protected function validateRFC2616Date(string $dateHeader): bool
    {
        $date = HTTP\parseDate($dateHeader);

        // Unknown format
        if (!$date) {
            $this->errorCode = self::ERR_INVALIDDATEFORMAT;

            return false;
        }

        $min = new \DateTime('-15 minutes');
        $max = new \DateTime('+15 minutes');

        // We allow 15 minutes around the current date/time
        if ($date > $max || $date < $min) {
            $this->errorCode = self::ERR_REQUESTTIMESKEWED;

            return false;
        }

        return true;
    }
protected function validateRFC2616Date(string $dateHeader): bool
    {
        $date = HTTP\parseDate($dateHeader);

        // Unknown format
        if (!$date) {
            $this->errorCode = self::ERR_INVALIDDATEFORMAT;

            return false;
        }

        $min = new \DateTime('-15 minutes');
        $max = new \DateTime('+15 minutes');

        // We allow 15 minutes around the current date/time
        if ($date > $max || $date < $min) {
            $this->errorCode = self::ERR_REQUESTTIMESKEWED;

            return false;
        }

        return true;
    }
protected function validateRFC2616Date ( string $ dateHeader ) : bool { $ date = HTTP \ parseDate ( $ dateHeader ) ; // Unknown format if ( ! $ date ) { $ this -> errorCode = self :: ERR_INVALIDDATEFORMAT ; return false ; } $ min = new \ DateTime ( '-15 minutes' ) ; $ max = new \ DateTime ( '+15 minutes' ) ; // We allow 15 minutes around the current date/time if ( $ date > $ max || $ date < $ min ) { $ this -> errorCode = self :: ERR_REQUESTTIMESKEWED ; return false ; } return true ; }
Makes sure the supplied value is a valid RFC2616 date.

If we would just use strtotime to get a valid timestamp, we have no way of checking if a
user just supplied the word 'now' for the date header.

This function also makes sure the Date header is within 15 minutes of the operating
system date, to prevent replay attacks.
Makes sure the supplied value is a valid RFC2616 date .