php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Problem with message date (failed to parse time string)

Open bjaverhagen opened this issue 2 years ago • 2 comments

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!

bjaverhagen avatar Nov 12 '23 12:11 bjaverhagen

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;

bjaverhagen avatar Nov 25 '23 14:11 bjaverhagen

I fixed it by adding a small code to the parseDate function in Header.php

image

bjaverhagen avatar Nov 25 '23 15:11 bjaverhagen