/ Published in: PHP
URL: http://us2.php.net/checkdate
Expand |
Embed | Plain Text
/* 解説:式を日付に変換できるかどうかを調べ、結果をブール値で返します 引数: $value 日付を示す文字列を指定します $format フォーマット文字列 返り値: True 指定した式が日付に変換できる False 指定した式が日付に変換できない */ function is_date($value, $format = 'yyyy/mm/dd'){ // find separator. Remove all other characters from $format $separator = $separator_only[0]; // separator is first character // make regex // check date return true; } } } return false; } $check1 = is_date('2009/01/01'); $check2 = is_date('2009/00/00'); echo "<hr>"; //●実行結果 //1 //-------------------------------------------------------------------------------- //0
You need to login to post a comment.
