Monday, October 22, 2012

PHP Function to check whether a given date is valid or not.

Here is a Simple Function to check whether a given date is valid or not.



           function is_valid_date($value, $separator='-')
{
              if(strlen($value) <= 10)
                        {
                        // check date
                        $arr=explode($separator,$value);
                        $day=$arr[2];
                        $month=$arr[1];
                        $year=$arr[0];
                        if(@checkdate($month, $day, $year))
                                    return true;
              }
             return false;
}

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...