// JavaScript Document window.onload=ShowSpring(); function ShowSpring(){ var Now= new Date();//获取当前时间 var SpringDate=new Date(2012,1,23);//指定时间 var SpringTime=SpringDate.getTime();//获得时间 var NowTime=Now.getTime();//获得当前时间 var TimeSub=SpringTime-NowTime; //天 var DaySub=TimeSub/(1000*60*60*24); DaySub=Math.floor(DaySub); //小时 var HourSub=TimeSub/(1000*60*60); HourSub=Math.floor(HourSub); //分钟 var MinutesSub=TimeSub/(1000*60); MinutesSub=Math.floor(MinutesSub); //秒钟 var SecondsSub=TimeSub/(1000); SecondsSub=Math.floor(SecondsSub); var resultDay="距离2012年的春节还有"+DaySub+"天"+HourSub+"小时"+MinutesSub+"分"+SecondsSub+"秒"; alert(resultDay); }
赞同楼上