Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

sql dates to european dates (See related posts)

converts sql dates to european dates and reverse.
2005-04-02 -> 02.04.2005
02.04.2005 -> 2005-04-02


function SqlToEuroDate($date) {
        $fd = substr($date, 8, 2)+0;
        $fm = substr($date, 5, 2)+0;
        $fy = substr($date, 0, 4);
        if ($fm<10) $fm = '0'.$fm;
        if ($fd<10) $fd = '0'.$fd;
        return  $newdate = $fd.'.'.$fm.'.'.$fy;
}

function EuroToSqlDate($date) {
        $fd = substr($date, 0, 2)+0;
        $fm = substr($date, 3, 2)+0;
        $fy = substr($date, 6, 4);
        if ($fm<10) $fm = '0'.$fm;
        if ($fd<10) $fd = '0'.$fd;
        return  $newdate = $fy.'-'.$fm.'-'.$fd;
}


You need to create an account or log in to post comments to this site.


Related Posts