比较某两个时间的时间戳相等

361 阅读1分钟
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>时间戳相等</title>
</head>
<body>

</body>
</html>
<script>
    var myDate = new Date();
    var stringTime=myDate.getFullYear()+'-'+(myDate.getMonth()+1)+'-'+myDate.getDate()+' '+'11:00:00'
    setInterval(function () {
        var timestamp = new Date(stringTime).getTime()
        var timestamp1 = Date.parse(new Date());
        console.log(timestamp)
        console.log(timestamp1)
        if(timestamp==timestamp1){
            console.log('时间到')
            console.log(timestamp)
            console.log(timestamp1)
        }
    },1000)
</script>