note 98068 deleted from function.strtotime by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: koen at thomeer dot be 

----

Here is a more advanced example of a version that works for people outside of the US. It can recognise dd-mm-yy and dd/mm/yy.

<?php
function strtotime_nonus($date)
{
    if(is_null($date) or ($date == ""))
        return False;
    if(strpos($date, '/')) {
        // break out components with '/', maximum of 3 elements
        $components = explode("/", $date, 3);
    }
    elseif(strpos($date, '-')) {
        // break out components with '-', maximum of 3 elements
        $components = explode("-", $date, 3);
    };
    $count = count($components);
    if($count > 1) // There is a slash
    {
        $tmp = $components[0]; // Swap first and second components
        $components[0] = $components[1];
        $components[1] = $tmp;
    }
    return strtotime(implode("/",$components)); // Put back together
};
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.