[英]Difference between two dates in javascript
Hi friends this piece of code is not returning the correct time difference between two times instead returning NaN can any one spot the mistake in my code , thanks in advance . 嗨,朋友,这段代码没有返回两次之间的正确时差,而是返回NaN可以在我的代码中发现任何错误,在此先感谢。
$("[id^='endTime']").change(function(){
var index = $(this).attr('id').slice(7);
var startTime = $('#startTime'+index).val();
var endTime = $(this).val();
var result = (new Date(startTime.val) - new Date(endTime.val));
alert(parseInt(result , 10));
$('#result'+index).val(parseInt(endTime , 10) - parseInt(startTime , 10)); ;
取出.val
来自new Date(startTime.val)
和new Date(endTime.val)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.