php-imap
php-imap copied to clipboard
Problem with message date (failed to parse time string)
Hi,
I'm having a problem retrieving the messages. Some messages contain dates that indicate an error. I've looked for solutions to this but can't find a proper solution.
Error: DateTime::modify(): Failed to parse time string (Fri, 10 Nov 2023 09:19:34 +0100 (W. Europe Standard Time)) at position 36 (E): Double timezone specification.
Is there a solution fot this problem? Thanks in advance!
I tried the following code in Header.php but it doesn't work:
// match case for: Fri, 10 Nov 2023 09:19:34 +0100 (W. Europe Standard Time)/Fri, 10 Nov 2023 09:19:34 +0100 (W. Europe Standard Time)
case preg_match('/([A-Z]{2,3}\,\ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4}\ \([A-Z]{1}\.\ [A-Z ]{3,20}\))\/([A-Z]{2,3}\,\ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4}\ \([A-Z]{1}\.\ [A-Z ]{3,20}\))+$/i', $date) > 0:
$dates = explode('/', $date);
$date = array_shift($dates);
$array = explode(',', $date);
array_shift($array);
$date = trim(implode(',', $array));
$array = explode('(', $date);
array_pop($array);
$date = trim(implode(' ', $array));
$date = Carbon::createFromFormat("d M Y H:i:s O", $date);
break;
I fixed it by adding a small code to the parseDate function in Header.php