我在网上看了一些这样的例子,可是都不是我想要的,希望大侠们能按照我所说的,给个相关的案例,谢谢,
是这样的,首先我的数据库有个职位表,发布职位的时候有个发布时间,然后给他定义一个大概几天的一个时间,然后去倒计时,等到了这个时间之后那个信息不能用了,或者换个颜色,给个提示之类的,谢谢!在线等
是这样的,首先我的数据库有个职位表,发布职位的时候有个发布时间,然后给他定义一个大概几天的一个时间,然后去倒计时,等到了这个时间之后那个信息不能用了,或者换个颜色,给个提示之类的,谢谢!在线等
日期年月日的int类型
调用的时候添个条件"where Addtime+day<"+当前日期的int类型
<script language="javaScript" type="text/javascript">
var timedate= new Date("June 26,2010");
var times= "2010中考";
var now = new Date();
var date = timedate.getTime() - now.getTime();
var time = Math.floor(date / (1000 * 60 * 60 * 24));
if (time >= 0)
document.write( "现在离"+times+"还有: "+time +"天")
</script>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="text-align:center;">
<font style="font-weight:bolder; font-size:x-large;">离2010年10月1日 20:00:00 还剩余</font><br /><br />
<asp:Label ID="hour" runat="server" ForeColor="Red" Font-Size="XX-Large" ></asp:Label> 小时
<asp:Label ID="min" runat="server" ForeColor="Red" Font-Size="XX-Large"></asp:Label> 分
<asp:Label ID="sec" runat="server" ForeColor="Red" Font-Size="XX-Large"></asp:Label> 秒
</div>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="1000">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
protected void Timer1_Tick(object sender, EventArgs e)
{
this.Timer1.Interval = 1000;
getTm();
} private void getTm()
{
DateTime curTm = DateTime.Now;
DateTime endTm = Convert.ToDateTime("2010-10-1");
this.hour.Text = (endTm - curTm).Hours.ToString();
this.min.Text = (endTm - curTm).Minutes.ToString();
this.sec.Text = (endTm - curTm).Seconds.ToString();
}
总之你可以存到一个结束时间,你存的时候就存结束时间,开始时间只是一个记录
1,(判断当前时间是否答应结束时间)首先我要跟你说的是 时间相减法则(数据库查询可以相减,代码里面也可以相减)(结束时间-当前时间=秒)
2,转换成秒了 放到页面上,用JS的 setTimeout 这个方法执行就好了,当秒小于0时 也就是说结束了,这样性能最好。
{
DateTime nowday,endday;
string leftday;
nowday = DateTime.Now;
endday = Convert.ToDateTime("2011-2-3");
this.lbllefttime.Text = (endday - nowday).Days.ToString();
this.label4.Text = (endday - nowday).Hours.ToString();
this.label6.Text = (endday - nowday).Minutes.ToString();
this.label9.Text = (endday - nowday).Seconds.ToString();
}