Curby: Datumsfeld in MySQL Datenbank speichern

Beitrag lesen

Hier ein Beispiel:
einfach die funktion irgendwo in das script haun am besten am anfang und dann die funktion auf die variable anwenden. z.B. $datum = $chdate($datum);

//Funktionsbeispiel zum ändern in das Mysql DATE format
    function chdate($text1)
    {
        $match1 = "/[1]+.[0-9]+.[0-9]+/i";
        $match2 = "/[2]+-[0-9]+-[0-9]+/i";

if(preg_match($match1, $text1))
        {
            $text2 = explode(".", $text1);
            return $text2[2] ."-". $text2[1] ."-". $text2[0];
        }
        elseif(preg_match($match2, $text1))
        {
            $text2 = explode("-", $text1);
            return $text2[2] .".". $text2[1] .".". $text2[0];
        }

}


  1. 0-9 ↩︎

  2. 0-9 ↩︎