Make two Date objects out of them. Then you can compare.
Get the value out of both dates you wish to compare, and make a subtraction. Like this (supposing foo
and bar
are dates):
var totalMilliseconds = foo - bar;
That will give you the amount of milliseconds between both. Some math will convert that to days, hours, minutes, seconds or whatever unit you wish to use. For example:
var seconds = totalMilliseconds / 1000;
var hours = totalMilliseconds / (1000 * 3600);
As for obtaining a Date
from a string
, you'll have to look into the constructor (check the first link), and use it in the way that suits you best. Happy coding!