jsmitty12 / phpWhois

phpWhois general repository
GNU General Public License v2.0
56 stars 20 forks source link

[ErrorException] A non-numeric value encountered #77

Open alglyzin opened 4 years ago

alglyzin commented 4 years ago

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 commented 4 years ago

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);
    }
e7o-de commented 2 years ago

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.