I have a jQuery clock that gives the time from 00:00 to 23:00.
Now I want to calculate the time difference between two times. Suppose the "in" time is 11:00, and the "out" time is 16:00.
How do I calculate the time difference in javascript?
You can use Date and setHours like that:
var first = new Date(); first.setHours(0, 11, 0, 0); var second = new Date(); second.setHours(0, 16, 0, 0); alert("Diff in seconds: " + (second - first));
1.4m articles
1.4m replys
5 comments
57.0k users