1. 程式人生 > >php 檢測時間是否正確

php 檢測時間是否正確

function check_Datetime($str, $format = "Y-m-d H:i:s"){
    $time = strtotime($str);  //轉換為時間戳
    $checkstr = date($format, $time); //在轉換為時間格式
    if($str == $checkstr){
        return true;
    }else{
        return false;
    }
}