phpWhois icon indicating copy to clipboard operation
phpWhois copied to clipboard

[ErrorException] A non-numeric value encountered

Open alglyzin opened this issue 5 years ago • 2 comments

https://github.com/jsmitty12/phpWhois/blob/3918cb2982b70bfb4a21939d2e37cc4fc6ded28e/src/whois.parser.php#L905

Using whois: artphone.co.il Problem parse date for line: "domain-registrar AT isoc.org.il 20201019 (Assigned)"

photo_2020-11-03_17-57-49

alglyzin avatar Nov 03 '20 15:11 alglyzin

Add whois.parser.php (function parseStandardDate())

    // EXAMPLE: domain-registrar AT isoc.org.il 20201019 (Assigned)
    $pattern = '/\s(\d{4})(\d{2})(\d{2})\s?|$/';
    if (preg_match_all($pattern, $date, $matches, PREG_SET_ORDER, 0) !== false) {
        $dateTimeFormat = 'Y-m-d';
        $date = "{$matches[0][1]}-{$matches[0][2]}-{$matches[0][3]}";
        $utc = new DateTimeZone('UTC');
        return Datetime::createFromFormat($dateTimeFormat, $date, $utc);
    }

alglyzin avatar Nov 03 '20 16:11 alglyzin

Got this message for the value

Updated Date: 0001-01-01T00:00:00.00Z

That "if value < 70" needs at least a is_numeric to prevent this error; better would be a null value returned for this kind of dates.

e7o-de avatar Mar 14 '22 09:03 e7o-de