Javascript Cookie将在一小时后过期?

Javascript Cookie将在一小时后过期?,javascript,cookies,Javascript,Cookies,我压缩了下面的javascript代码,将cookie应用于DocumentReady上弹出的模式框。我如何调整以下内容,使饼干只持续一小时?我想现在它会永远持续下去吗 function setCookie(cookieName,cookieValue,nDays) { var today = new Date(); var expire = new Date(); if (nDays==null || nDays==0) nDays=1; expire.setTime(today.ge

我压缩了下面的javascript代码,将cookie应用于DocumentReady上弹出的模式框。我如何调整以下内容,使饼干只持续一小时?我想现在它会永远持续下去吗

function setCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function getCookie(cookieName) {
 var theCookie=" "+document.cookie;
 var ind=theCookie.indexOf(" "+cookieName+"=");
 if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"=");
 if (ind==-1 || cookieName=="") return "";
 var ind1=theCookie.indexOf(";",ind+1);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+2,ind1));
}

    $(document).ready(function() {

        var skipModal = getCookie('skipModal');
     if (!skipModal) { // check and see if a cookie exists indicating we should skip the modal
         $('#myModal').reveal({
     animation: 'fadeAndPop',                   //fade, fadeAndPop, none
     animationspeed: 300,                       //how fast animtions are
     closeonbackgroundclick: true,              //if you click background will modal close?
     dismissmodalclass: 'close-reveal-modal'    //the class of a button or element that will close an open modal
    });


         setCookie('skipModal', 'true', 365*5); // set a cookie indicating we should skip the modal
     }
});

Javascript时间以毫秒表示,所以更改

expire.setTime(今天.getTime()+3600000*24*nDays)


expire.setTime(today.getTime()+(60*60*1000))

Javascript时间以毫秒表示,因此更改

expire.setTime(今天.getTime()+3600000*24*nDays)


expire.setTime(today.getTime()+(60*60*1000))

我会使用getHours方法

var expire = new Date();
expire.setHours(expire.getHours()+1);
//test
alert(expire.toUTCString());

我会使用getHours方法

var expire = new Date();
expire.setHours(expire.getHours()+1);
//test
alert(expire.toUTCString());