Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <%
  2. Function TimeSpan(dt1, dt2)
  3. If (isDate(dt1) And IsDate(dt2)) = false Then
  4. TimeSpan = "00:00:00"
  5. Exit Function
  6. End If
  7.  
  8. seconds = Abs(DateDiff("S", dt1, dt2))
  9. minutes = seconds 60
  10. hours = minutes 60
  11. minutes = minutes mod 60
  12. seconds = seconds mod 60
  13.  
  14. if len(hours) = 1 then hours = "0" & hours
  15.  
  16. TimeSpan = hours & ":" & _
  17. RIGHT("00" & minutes, 2) & ":" & _
  18. RIGHT("00" & seconds, 2)
  19. End Function
  20.  
  21. d1 = "2002-03-27 9:20:25 AM"
  22. d2 = "2002-03-27 9:20:45 AM"
  23.  
  24. Response.Write TimeSpan(d1, d2)
  25. %>
  26.  
  27. <%
  28. Function TimeSpan(dt1, dt2)
  29. If (isDate(dt1) And IsDate(dt2)) = false Then
  30. TimeSpan = "00:00:00"
  31. Exit Function
  32. End If
  33.  
  34. seconds = Abs(DateDiff("S", dt1, dt2))
  35. minutes = seconds 60
  36. hours = minutes 60
  37. days = hours 24
  38. minutes = minutes mod 60
  39. seconds = seconds mod 60
  40. hours = hours mod 24
  41.  
  42. if len(hours) = 1 then hours = "0" & hours
  43.  
  44. TimeSpan = days& ":" & _
  45. RIGHT("00" & hours , 2) & ":" & _
  46. RIGHT("00" & minutes, 2)
  47. End Function
  48.  
  49. d1 = "2002-03-27 9:20:25 AM"
  50. d2 = "2002-03-27 9:20:45 AM"
  51.  
  52. Response.Write TimeSpan(d1, d2)
  53. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement