如何在JavaScript中将long转换为int?

此HTML文件计算当前日期和选定日期之间的天数差,只要该日期晚于今天。

代码如下:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Calcolo distanza</title>
    </head>
    <body onload="myFunction()">
    <p> Data corrente </p>
    <button type="button" id="myBtn"></button>
    <p> Scegli la data </p>
    <input type="date" id="dataCorrente">
    <input type="submit" onclick="calcola()">
    <br>
    <p id="Risultato"> </p>

    </body>
    <script>
        var d= new Date();
        function myFunction(){
            console.log("onload()");
            console.log(d);
            document.getElementById("myBtn").innerHTML=d.toDateString();
        }
        function calcola(){
            var input = document.getElementById("dataCorrente").value;
            if(input!=null){
                var dat=new Date();
                dat.setHours(0);
                dat.setMinutes(0);
                dat.setSeconds(0);
                var data = new Date(input); 
                var mill1=dat.getTime();
                var mill2=data.getTime();
                if(mill2>mill1){
                    mill2=mill2-mill1;
                    var ris=mill2/86400000;
                    document.getElementById("Risultato").innerHTML=ris;
                }
                else{
                    document.getElementById("Risultato").innerHTML="La data deve essere maggiore di quella corrente";
                }
            }
            else{
                console.log("input=null");
                document.getElementById("Risultato").innerHTML="Data non inserita";
            }
        }
    </script>
    </html>