Return to Snippet

Revision: 22452
at January 13, 2010 01:40 by giak


Initial Code
// transforme une date 31/07/2007 en 2007-07-31 et inversemment sans heure
function neo_date_transform ($date, $separator){
    switch ($separator) {
        case "/":
            $split = split("/", $date);
            $jour = $split[0];
            $mois = $split[1];
            $annee = $split[2];
            return $date = $annee . "-" . $mois . "-" . $jour;
        case "-":
            $split = split("-", $date);
            $annee = $split[0];
            $mois = $split[1];
            $jour = substr($split[2], 0, 2); // enleve l'heure
            return $date = $jour . "/" . $mois . "/" . $annee;
    }
}

Initial URL
http://www.giacomel.fr

Initial Description

                                

Initial Title
PHP : form a date with slash or dash

Initial Tags
date

Initial Language
PHP