
js 判断时间是否过期
<html><head></head><body><scriptlanguage="LiveScript"><!--HidingdocStarted=newDate(12...
<html>
<head>
</head>
<body>
<script language="LiveScript">
<!-- Hiding
docStarted = new Date(12,0,18)
document.write("<br>过期日期: ", docStarted.getMonth()+1,"/",docStarted.getDate(),"/",docStarted.getYear());
// end hiding contents -->
</script>
<script language="LiveScript">
<!-- Hiding
today = new Date()
document.write("<br>现 在 时 间 是: ",today.getHours(),":",today.getMinutes())
document.write("<br>今 天 日 期 为: ", today.getMonth()+1,"/",today.getDate(),"/",today.getYear());
// end hiding contents -->
</script>
<br>
</body>
</html>
目的是设计一个10天后弹出个提示框说东西过期了。这个的判断如何写。。 展开
<head>
</head>
<body>
<script language="LiveScript">
<!-- Hiding
docStarted = new Date(12,0,18)
document.write("<br>过期日期: ", docStarted.getMonth()+1,"/",docStarted.getDate(),"/",docStarted.getYear());
// end hiding contents -->
</script>
<script language="LiveScript">
<!-- Hiding
today = new Date()
document.write("<br>现 在 时 间 是: ",today.getHours(),":",today.getMinutes())
document.write("<br>今 天 日 期 为: ", today.getMonth()+1,"/",today.getDate(),"/",today.getYear());
// end hiding contents -->
</script>
<br>
</body>
</html>
目的是设计一个10天后弹出个提示框说东西过期了。这个的判断如何写。。 展开
2个回答
展开全部
你的代码我没看,说下我的思路,你把日期格式转换一下,能比较大小,如果你的当前日期比过期时间靠后,也就是大,那么就说明过期了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
调用getTime()来比较
if(docStarted .getTime()< today .getTime()){
alert("过期");
}
if(docStarted .getTime()< today .getTime()){
alert("过期");
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询