Re: validating mysql bound date

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

 



On Tue, Mar 4, 2008 at 8:16 PM, Larry Brown
<larry.brown@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Does anyone know if there is a builtin function for checking the
>  formatting of an incoming date to verify it is YYYY/MM/DD.  I know how
>  to convert between formats but want a quick way to check an incoming
>  variable to ensure it will be handled properly by mysqld.

    Larry, try this:
<?
function verifyDate($strDate) {
        if(preg_match('/(19|20)?\d\d[-](0?[1-9]|1[012])[-](0?[1-9]|[12][0-3]|3[01])/',$strDate))
{
                return True;
        } else {
                return False;
        }
}
?>

    It's also up in my snippet library here:
        [Demo]    http://www.pilotpig.net/code-library/date-format-check.php
        [Source]
http://www.pilotpig.net/code-library/source.php?f=date-format-check.php

-- 
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

-- 
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