var myDate = new Date(); function returnEndDate(y,m,d,h,m){ myDate.setYear(myDate.getFullYear()+y); myDate.setMonth(myDate.getMonth()+m); myDate.setDate(myDate.getDate()+d); myDate.setHours(myDate.getHours()+h); myDate.setMinutes(myDate.getMinutes()+m); return myDate; } $(function(){ var dbt=new Date(dateEnd); var str_dbt=dbt.getFullYear()+'/'+ dbt.getMonth()+'/'+dbt.getDate(); $('.countdown_text').html(dbt.getDate()+"."+(dbt.getMonth()+1)+"."+dbt.getFullYear()); }); var dateForCookie = new Date(); var cookieMins = 179; dateForCookie.setTime(dateForCookie.getTime() + (cookieMins * 60 * 1000)); if($.cookie("timer")){ var dateEnd = $.cookie("timer"); }else{ var dateEnd = returnEndDate(0,0,2,0,0); $.cookie("timer", dateEnd, {expires: dateForCookie}); } dateEnd = new Date(dateEnd); var year = dateEnd.getFullYear(), month = dateEnd.getMonth() + 1, day = dateEnd.getDate(), hour= dateEnd.getHours(), minute= dateEnd.getMinutes(), sec= 0; month = --month; var dateFuture = new Date(year, month, day, hour, minute, sec); function CountBox() { var dateNow = new Date; var amount = dateFuture.getTime() - dateNow.getTime() + 5; delete dateNow; if (amount < 0) { var out = "
0
0
" + "
" + "
0
0
" + "
:
" + "
0
0
"; document.getElementById("countbox").innerHTML = out; } else { var hours = 0, hours1 = 0, hours2 = 0, mins = 0, mins1 = 0, mins2 = 0, secs = 0, secs1 = 0, secs2 = 0, out = ""; amount = Math.floor(amount / 1e3); amount = amount % 86400; hours = Math.floor(amount / 3600); hours1 = (hours >= 10) ? hours.toString().charAt(0) : '0'; hours2 = (hours >= 10) ? hours.toString().charAt(1) : hours.toString().charAt(0); amount = amount % 3600; mins = Math.floor(amount / 60); mins1 = (mins >= 10) ? mins.toString().charAt(0) : '0'; mins2 = (mins >= 10) ? mins.toString().charAt(1) : mins.toString().charAt(0); amount = amount % 60; secs = Math.floor(amount); secs1 = (secs >= 10) ? secs.toString().charAt(0) : '0'; secs2 = (secs >= 10) ? secs.toString().charAt(1) : secs.toString().charAt(0); out = "
" + hours1 + "
" + hours2 + "
" + "
" + "
" + mins1 + "
" + mins2 + "
" + "
:
" + "
" + secs1 + "
" + secs2 + "
"; document.getElementById("countbox").innerHTML = out; document.getElementById("countbox1").innerHTML = out; setTimeout("CountBox()", 1e3) } } window.onload = function () { CountBox() };