JS判断时间是否早晚于当前时间

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>时间判断</title>
</head>
<body>
    <script type="text/javascript" >
        var thetime = '2018-04-17 19:09:00';
        var   d=new   Date(Date.parse(thetime .replace(/-/g,"/")));

        var   curDate=new   Date();
        if(d <=curDate){
            alert("小于当前时间");
        }else{
            alert("大于当前时间");
        }
    </script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/huangbaokang/article/details/79979304
今日推荐