新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
script
创新互联建站是一家专注于成都网站制作、做网站、外贸营销网站建设与策划设计,新化网站建设哪家好?创新互联建站做网站,专注于网站建设10多年,网设计领域的专业建站公司;建站业务涵盖:新化等地区。新化做网站价格咨询:18982081108
var d=new Date();
var dt=new Date();
dt.setFullYear(d.getFullYear(),5,7);
if(dtd)
{
dt.setFullYear(d.getFullYear()+1,5,7);
}
document.write("离高考还有"+(dt-d)/3600/24/1000+"天");
/script
改了,加了个判断。刚理解错了。。
这是2014年高考倒计时的代码,可以自己修改只需要更改BirthDay=new Date("7-6-2014"); 里面的数字就可以。测试可用。
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /
title无标题文档/title
/head
body onload="show_date_time()"
SCRIPT language=javascript
function show_date_time(){
window.setTimeout("show_date_time()", 1000);
BirthDay=new Date("7-6-2014");
today=new Date();
timeold=(BirthDay.getTime()-today.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=Math.floor(e_hrsold);
e_minsold=(e_hrsold-hrsold)*60;
minsold=Math.floor((e_hrsold-hrsold)*60);
seconds=Math.floor((e_minsold-minsold)*60);
span_dt_dt.innerHTML="balign=centerfont color=00CC00"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒"+"/bbr/font" ;
}
/SCRIPT
balign=centerfont color=#ffffff高考倒计时还有:/b/font
span id="span_dt_dt" style='align=center no:1px solid black;background-color:#FFFFFF' /span
/body
/html
!DOCTYPE html
html
head
meta charset="utf-8"
script type="text/javascript"
window.onload = function(){
function DistenceOfDate(year,month,day,hour,minute,seconds) {
var date = new Date();
var dateMill = date.getTime();
var targetDate = new Date(year,(month -1),day,hour,minute,seconds);
var targetMill = targetDate.getTime();
var perDay = 3600 * 1000 * 24;
var perHour = 3600*1000;
var perMin = 60000;
var perSec = 1000;
var offset = targetMill - dateMill ;
var tmp = offset % perDay;
var days = parseInt(offset / perDay);
log(days);
var offsetHour = tmp % perHour ;
var hours = parseInt(tmp/ perHour);
log(hours);
var offsetMin = offsetHour % perMin ;
var min = parseInt(offsetHour /perMin );
log(min);
var offsetSec = offsetMin % perSec ;
var secs = parseInt(offsetMin /perSec );
log(secs);
log(offsetSec);
function log (str){
console.log(str);
}
return{
day:days,
h:hours,
m:min,
s:secs,
ms:offsetSec
}
}
setInterval(function(){
var obj = DistenceOfDate(2014,11,30,00,00,00);
document.querySelector("#msg.msg").innerHTML ="距离 2014年11月30日0时0分0秒还有:/br"+obj.day+" 天 "+obj.h+" 小时 "+obj.m+" 分钟"+
obj.s+"秒 ";
},1000);
}
/script
style type="text/css"
.msg{
width: 100%;
height: 40px;
background: #1990d5;
color:#FBBDEE;
text-align: center;
}
/style
/head
body
div id="msg" class="msg"/div
/body
/html
刚写的热乎的。程序精确到秒啦
var scount = 0;
$(function () {
var start = setInterval(function () {
var dtstr = "";
var now = new Date();//初始化当前时间
var newdatr = new Date(now.getFullYear(), "05", "07", "00", "00", "00", "00");//初始化目标时间(这里的05实际上是六月)
var nowhms = now.getTime();//当前时间转换毫秒
var newhms = newdatr.getTime();//目标时间转换毫秒
var cha = newhms - nowhms;//时间差(毫秒数)
if (cha 0) {
var day = parseInt(cha / (1000 * 60 * 60 * 24));//计算天数
var hh = parseInt((cha % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));//计算小时
var min = parseInt(((cha % (1000 * 60 * 60 * 24)) % (1000 * 60 * 60)) / (1000 * 60));//计算分钟
var ss = parseInt((((cha % (1000 * 60 * 60 * 24)) % (1000 * 60 * 60)) % (1000 * 60)) / 1000);//计算秒
if (ss == 0) {
scount += 1;
}
//var ms = parseInt((((cha % (1000 * 60 * 60 * 24)) % (1000 * 60 * 60)) % (1000 * 60)) % 1000);
dtstr = day + "天" + hh + "小时" + min + "分钟" + ss + "秒";//+ ms + "毫秒";
}
$("#timestr").html(dtstr);
$("#flag").html("你已经续了" + scount + "分钟。");
}, 1000);
});