我们可以使用VBScript以Day-Hour-Minutes格式获得两个日期值差异吗?
答案 0 :(得分:8)
这是一个HH :: MM:SS示例,将其更改为DD :: HH :: MM应该很容易
HH-MM-ss.html
<%
Function TimeSpan(dt1, dt2)
If (isDate(dt1) And IsDate(dt2)) = false Then
TimeSpan = "00:00:00"
Exit Function
End If
seconds = Abs(DateDiff("S", dt1, dt2))
minutes = seconds \ 60
hours = minutes \ 60
minutes = minutes mod 60
seconds = seconds mod 60
if len(hours) = 1 then hours = "0" & hours
TimeSpan = hours & ":" & _
RIGHT("00" & minutes, 2) & ":" & _
RIGHT("00" & seconds, 2)
End Function
d1 = "2002-03-27 9:20:25 AM"
d2 = "2002-03-27 9:20:45 AM"
Response.Write TimeSpan(d1, d2)
%>
类似的东西:(我不确定,我不知道vbscript)
<%
Function TimeSpan(dt1, dt2)
If (isDate(dt1) And IsDate(dt2)) = false Then
TimeSpan = "00:00:00"
Exit Function
End If
seconds = Abs(DateDiff("S", dt1, dt2))
minutes = seconds \ 60
hours = minutes \ 60
days = hours \ 24
minutes = minutes mod 60
seconds = seconds mod 60
hours = hours mod 24
if len(hours) = 1 then hours = "0" & hours
TimeSpan = days& ":" & _
RIGHT("00" & hours , 2) & ":" & _
RIGHT("00" & minutes, 2)
End Function
d1 = "2002-03-27 9:20:25 AM"
d2 = "2002-03-27 9:20:45 AM"
Response.Write TimeSpan(d1, d2)
%>