Bonsoir,
Qui peut m'expliquer le but de ce bout de code, je cherche à convertir n'importe qu'elle date en fonction de time zone en date locale ou plutôt date de mon serveur qui se trouve en Europe.
Normalement je doit tomber sur une date $unix =< time() une fois converti
if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s+)?(\d{1,2})\s+([a-zA-Z]{3})\s+(\d{4})\s+(\d{2}):(\d{2}):(\d{2})\s+(.*)~", $pubDate, $matches)) {
            $months = Array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12);
            $unix = mktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]);
            if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') {
                $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;
            } else {
                if (strlen($matches[7])==1) {
                    $oneHour = 3600;
                    $ord = ord($matches[7]);
                    if ($ord < ord("M")) {
                        $tzOffset = (ord("A") - $ord - 1) * $oneHour;
                    } elseif ($ord >= ord("M") AND $matches[7]!="Z") {
                        $tzOffset = ($ord - ord("M")) * $oneHour;
                    } elseif ($matches[7]=="Z") {
                        $tzOffset = 0;
                    }
                }
                switch ($matches[7]) {
                    case "UT":
                    case "GMT":    $tzOffset = 0;
                }
            }
            $unix += $tzOffset;
        }        
        
        if (preg_match("~(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(.*)~",$pubDate,$matches)) {
            $unix = mktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]);
            if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') {
                $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;
            } else {
                if ($matches[7]=="Z") {
                    $tzOffset = 0;
                }
            }
            $unix += $tzOffset;
        }
Voiçi 3 exemples. Merci
date à convertir Mon, 05 Nov 2012 23:12:02 GMT
date locale Mon, 05 Nov 2012 22:39:31 +0100
Date converti 1352153522
timestemp now 1352151571
date à convertir Mon, 05 Nov 2012 22:10:11 +0100
date locale Mon, 05 Nov 2012 22:39:32 +0100
Date converti 1352153411
timestemp now 1352151572
date à convertir Mon, 05 Nov 2012 22:27:00 +0100
date locale Mon, 05 Nov 2012 22:39:32 +0100
Date converti 1352154420
timestemp now 1352151572