PHP imap在纪元时间从电子邮件中获取日期

It's not as easy as strtotime()...

I'm returning dates of emails with php imap. When I return a date, I get this formatting:

21 May 2015 20:48:36 -0400
Fri, 15 May 2015 00:13:12 +0000
Fri, 7 Aug 2015 07:11:42 -0400 (EDT)
Fri, 4 Sep 2015 11:03:15 -0400
Mon, 10 Aug 2015 22:04:10 +0000
Tue, 14 Jul 2015 12:54:47 -0400
Sun, 21 Jun 2015 10:49:06 +0000
Fri, 12 Jun 2015 17:35:26 +0000
Thu, 27 Aug 2015 11:47:55 -0400
Mon, 20 Jul 2015 12:43:45 -0400
Fri, 18 Sep 2015 07:47:04 -0400 (EDT)
etc.

As you can see, the dates aren't exactly consistent. One of the dates does not have a day name (Fri). Some of the dates have an (EDT) tag on it, and the others don't.

I tried using strtotime($date), but I believe that since it has the time zone in some of them, it's messing the date up.

Is there a way to convert these very strange times into epoch time?

You could clean up your input before processing it as time strings:

$input = "21 May 2015 20:48:36 -0400
Fri, 15 May 2015 00:13:12 +0000
Fri, 7 Aug 2015 07:11:42 -0400 (EDT)
Fri, 4 Sep 2015 11:03:15 -0400
Mon, 10 Aug 2015 22:04:10 +0000
Tue, 14 Jul 2015 12:54:47 -0400
Sun, 21 Jun 2015 10:49:06 +0000
Fri, 12 Jun 2015 17:35:26 +0000
Thu, 27 Aug 2015 11:47:55 -0400
Mon, 20 Jul 2015 12:43:45 -0400
Fri, 18 Sep 2015 07:47:04 -0400 (EDT)";

$output = '';

$lines = explode("
", $input);

foreach($lines as $line) {
    $output .= preg_replace('/(\w{3}, )|( \(\w{3}\))/', '', $line)."
";
}

echo $output;