Javascript添加两次并检查条件

Javascript adding two times and checking condition

本文关键字:两次 检查 条件 添加 Javascript      更新时间:2023-09-26

我无法在java-script中添加两次。我使用了这样的代码

var dbEndtime1 = new Date(dbEndtime);
var hours  = dbEndtime1.getHours();
alert(dbEndtime1 + " hours" + hours);

不给小时

dbEndtime="10:40:00"我想在此添加小时数,并且再次到来的值我需要检查1:00:00.,如total-time=10:40:00+5hours, total-time>1:00:00total-time<24:00:00

我想实现这个逻辑。

这是我的解决方案

var now = new Date("2013/1/1 02:14");
now.setHours(now.getHours()+5);

alert(now.getHours())
if(now.getHours()==1 && now.getMinutes()==0 && now.getSeconds()==0){
  //It 's 1:00:00
}
http://jsfiddle.net/sechou/2SLPm/