Make two Date objects from them. Then you can compare.
Get the value from both dates you want to compare and do a subtraction. Similar to this (suppose foo and bar are dates):
var totalMilliseconds = foo - bar;
This will give you milliseconds between them. Some math will convert this to days, hours, minutes, seconds, or whatever you want to use. For instance:
var seconds = totalMilliseconds / 1000; var hours = totalMilliseconds / (1000 * 3600);
As for getting Date from string , you will need to study the constructor (check the first link) and use it the way you want. Happy coding!
Renan source share