From f32de0a848a0407e45eeda14611e6cf61b7ee753 Mon Sep 17 00:00:00 2001 From: Hosteroid Date: Tue, 3 Feb 2026 15:49:50 +0200 Subject: [PATCH] Support DD/MM/YYYY WHOIS date parsing Add handling for European-style dates (DD/MM/YYYY and DD/MM/YYYY HH:MM:SS) before calling strtotime. The code detects a leading DD/MM/YYYY pattern, interprets it as day/month/year when day>12 or when both day and month are <=12 (favoring European format used by many WHOIS servers like .pt, .es, .fr), then converts it to YYYY-MM-DD with any time part preserved. If month>12 the original string is left for strtotime to handle. This improves robust parsing of WHOIS date strings from servers that use day-first formats. --- app/Services/WhoisService.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/Services/WhoisService.php b/app/Services/WhoisService.php index 1a132f0..51a5b3a 100644 --- a/app/Services/WhoisService.php +++ b/app/Services/WhoisService.php @@ -1041,6 +1041,27 @@ class WhoisService $dateString = preg_replace('/^(before|after):/i', '', $dateString); $dateString = trim($dateString); + // Handle DD/MM/YYYY format (European format used by many WHOIS servers like .pt, .es, .fr, etc.) + // Pattern: DD/MM/YYYY or DD/MM/YYYY HH:MM:SS + if (preg_match('#^(\d{1,2})/(\d{1,2})/(\d{4})(.*)$#', $dateString, $matches)) { + $day = (int)$matches[1]; + $month = (int)$matches[2]; + $year = (int)$matches[3]; + $timePart = trim($matches[4]); + + // If day > 12, it's definitely DD/MM/YYYY format + // If month > 12, it's definitely MM/DD/YYYY format (invalid day, so swap) + // If both <= 12, assume DD/MM/YYYY (European format) as it's more common globally for WHOIS + if ($day > 12 || ($day <= 12 && $month <= 12)) { + // Treat as DD/MM/YYYY - convert to YYYY-MM-DD format + $dateString = sprintf('%04d-%02d-%02d', $year, $month, $day); + if (!empty($timePart)) { + $dateString .= ' ' . $timePart; + } + } + // If month > 12, strtotime will fail or we let it try MM/DD/YYYY naturally + } + // Try to parse the date $timestamp = strtotime($dateString);