转自:http://blog.sina.com.cn/s/blog_66f7fa5a0100tihx.html
aspx页面:
<br>距结束时间还有<br>
<span id="span_dt_dt" style='border:1px solid black;background-color:#FFFFFF' ></span>
<SCRIPT type="text/javascript">
<!--
//document.write("");
var timess='<asp:Literal ID="timess" runat="server"></asp:Literal>'
function show_student163_time(){
window.setTimeout("show_student163_time()", 1000);
BirthDay=new Date(timess);
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=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ;
}
show_student163_time();
//-->
</SCRIPT>
aspx.cs页面
protected void Page_Load(object sender, EventArgs e)
{
this.timess.Text = "12:10 05-6-2011";//可以动态查出所到期的时间
}