• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
内蒙古峰回路转armyfeng
博客园    首页    新随笔    联系   管理    订阅  订阅

时间倒计时例子

<Script Language="JavaScript">
/*
显示日期格式如:2004年05月28日 星期五
armyfeng
*/
now 
= new Date();
sMonth 
= "0" + (now.getMonth() + 1);
sDate 
= "0" + now.getDate();
sYear 
= now.getYear();
sDay 
= now.getDay();
sTime
= now.getTime();
sMonth 
= sMonth.substr(sMonth.length - 2);
sDate 
= sDate.substr(sDate.length - 2);
sYear 
= (sYear < 2000) ? sYear + 1900 : sYear;
sWeek 
= "星期" + String("日一二三四五六").substr(sDay, 1);

document.write(
"当前时间:"+ sYear + "年" + sMonth + "月" + sDate + "日" + " " + sWeek + " ")

var timedate= new Date("Jan 25,2007"); 
var times="北京奥运会"; 
var now = new Date(); 
  
var date = timedate.getTime() - now.getTime(); 
  
var time = Math.floor(date / (1000 * 60 * 60 * 24)); 
  
if (time >= 0) ;
document.write(
"<font style='font-size:12px;line-height:18px;color:#000000'>离2008"+times+"开幕还有:</font><font style='color:#F5A100;line-height:32px;font-family:Verdana;font-size:24px;'><b>"+time +"</b></font><font style='font-size:12px;line-height:18px;color:#000000'>天</font>");
</Script> 

<script language="JavaScript" type="text/javascript">
<!--
function show_date_time(){
var getdate
 window.setTimeout(
"show_date_time()", 1000);
 BirthDay
=new Date("08-08-2008");//改成你的计时日期
 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);
 getdate
=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ;
document.write(
"目的时间:"+ getdate)
}
show_date_time();
//-->
</script>
<div id="span_dt_dt"></div>
posted @ 2007-01-10 11:03  老冯  阅读(189)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3