It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                7年前关闭。
            
        

我尝试这段代码

start_time = '08:15 AM'
end_time = '03:45 PM'
diff = end_time - start_time;


只有我想减去jquery中的时间。我已经尝试在php中进行如下操作,并且运行正常。
但不在jQuery中

$st = strtotime("07:30 AM");
$edt = strtotime("06:15 AM");
echo round(abs($st - $edt) / 60,2). " minute";
echo "<br>";

echo $timediff=($edt-$st)/60;

最佳答案

使用Date()对象。您不能像问题中那样减去字符串。

a = new Date(2012, 1, 2, 21, 1, 3, 5)
b = new Date(2012, 2, 3, 22, 2, 3, 5)
c = a - b // diff in milliseconds

关于javascript - 如何减去jQuery中的时隙? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11865209/

10-12 20:35