Re: TimeStamp BEFORE 1970 AND AFTER 2035

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just a quick fix, as now I've tested in a real environment, with a real application, and now it's working 100%, well, I think so.

/ *********************************************************************
    *  Stritotime workaround for dates before 1970 and after 2038
*********************************************************************/
    function str2time($input = '01/01/1969')
    {
if(($timestamp = strtotime($input)) !== -1 && $timestamp !== false)
        {
            return (float)$timestamp;
        }
        else
        {
            preg_match('([0-9][0-9][0-9][0-9])', $input, $year);
            $input = str_replace($year[0], '1976', $input);
return (float)floor(strtotime($input) + (($year[0] - 1976) * (31557376.189582)));
        }
    }

Shoot!

Best Regards,
Bruno B B Magalhaes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux