public static function getDateTimeFromRfc($date) {

		// various date formats
		$formats = array(
				'RFC2822' => \DateTime::RFC2822,	// Fri, 06 Nov 2015 09:23:05 +0100
				'RFC2046' => 'D, d M Y H:i:s O T',	// Fri, 06 Nov 2015 09:23:05 +0100 (CET)
				'CUSTOM1' => 'D, j M Y H:i:s O',	// Fri, 6 Feb 2015 09:23:05 +0100
				'CUSTOM2' => 'd M Y H:i:s O',		// 06 Nov 2015 09:23:05 +0100
				'RSS2'    => 'D, d M Y H:i:s T');	// Tue, 10 May 2016 15:33:54 GMT
		
		// tries each date format
		foreach ($formats as $format) {

			$datetime = \DateTime::createFromFormat($format, $date, new \DateTimeZone(BASE_TIMEZONE));

			if (is_a($datetime, '\DateTime')) {
				return $datetime;
			}

		}

		return NULL;

	}
public static function getDateTimeFromRfc($date) {

		// various date formats
		$formats = array(
				'RFC2822' => \DateTime::RFC2822,	// Fri, 06 Nov 2015 09:23:05 +0100
				'RFC2046' => 'D, d M Y H:i:s O T',	// Fri, 06 Nov 2015 09:23:05 +0100 (CET)
				'CUSTOM1' => 'D, j M Y H:i:s O',	// Fri, 6 Feb 2015 09:23:05 +0100
				'CUSTOM2' => 'd M Y H:i:s O',		// 06 Nov 2015 09:23:05 +0100
				'RSS2'    => 'D, d M Y H:i:s T');	// Tue, 10 May 2016 15:33:54 GMT
		
		// tries each date format
		foreach ($formats as $format) {

			$datetime = \DateTime::createFromFormat($format, $date, new \DateTimeZone(BASE_TIMEZONE));

			if (is_a($datetime, '\DateTime')) {
				return $datetime;
			}

		}

		return NULL;

	}
public static function getDateTimeFromRfc ( $ date ) { // various date formats
 $ formats = array ( 'RFC2822' => \ DateTime :: RFC2822 , // Fri, 06 Nov 2015 09:23:05 +0100
 'RFC2046' => 'D, d M Y H:i:s O T' , // Fri, 06 Nov 2015 09:23:05 +0100 (CET)
 'CUSTOM1' => 'D, j M Y H:i:s O' , // Fri, 6 Feb 2015 09:23:05 +0100
 'CUSTOM2' => 'd M Y H:i:s O' , // 06 Nov 2015 09:23:05 +0100
 'RSS2' => 'D, d M Y H:i:s T' ) ; // Tue, 10 May 2016 15:33:54 GMT
 // tries each date format
 foreach ( $ formats as $ format ) { $ datetime = \ DateTime :: createFromFormat ( $ format , $ date , new \ DateTimeZone ( BASE_TIMEZONE ) ) ; if ( is_a ( $ datetime , '\DateTime' ) ) { return $ datetime ; } } return NULL ; }
Converts string date coming by email in various RFC formats to DateTime. If fails or gets
a date over current time, sets as now.

@param	string	Date in various formats.

@return	DateTime
Converts string date coming by email in various RFC formats to DateTime . If fails or gets a date over current time sets as now .