/ Published in: PHP
Function which can be used as wrapper for default PHP checkdate function. Will automatically parse given date (string or integer format).
Expand |
Embed | Plain Text
/** * Function to check if a given date actually exists / is valid * * @param strin|int $date * * @return boolean */ // Check if date is given // Check if given date is numeric } // Match the format of the date (YYYY-MM-DD YYYY/MM/DD YYYY.MM.DD) // Check weather the date is valid of not return true; } else { return false; } // Match the format of the date (DD-MM-YYYY DD/MM/YYYY DD.MM.YYYY) } elseif(preg_match ("/^([0-9]{1,2})[-\.\/]{1}([0-9]{1,2})[-\.\/]{1}([0-9]{4})$/", $date, $parts)) { return true; } else { return false; } } } return false; }
You need to login to post a comment.
