Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Compare Date and Time

I have two date time strings formated like so; 29/09/2009 15:19 & 29/09/2009 17:19 and basiclly all i want to do is compare the two date and time to see which is greater

Any Help?

like image 554
Dooie Avatar asked Dec 31 '09 09:12

Dooie


People also ask

Can JavaScript compare dates?

When we think of date comparison in JavaScript, we think of using the Date object ( Date() ) and, of course, it works. The date object allows us to perform comparisons using the > , < , = , or >= comparison operators, but not the equality comparison operators like == , != , === , and !==

Can JavaScript handle dates and time?

The Date object is a built-in object in JavaScript that stores the date and time. It provides a number of built-in methods for formatting and managing that data. By default, a new Date instance without arguments provided creates an object corresponding to the current date and time.

How can I compare two date and time in Java?

In Java, two dates can be compared using the compareTo() method of Comparable interface. This method returns '0' if both the dates are equal, it returns a value "greater than 0" if date1 is after date2 and it returns a value "less than 0" if date1 is before date2.


1 Answers

if ( Date.parse ( firstDateString ) > Date.parse ( secondDateString ) ) {
    // first date is greater
}
like image 93
Jan Hančič Avatar answered Sep 18 '22 18:09

Jan Hančič