Q: How to compare a previous DateTime with a current DateTime in JavaScript I'm creating a booking system, I want to make sure that users don't mistakenly select a previous date. I want the following pseudo code to be in JavaScript:
if(StartDateTime < Now && EndDateTime < Now)
{    
    alert("Bookings cannot be created for a previous date");
} 


A: var startDate = '5/5/2015'; // mm/dd/yyyy formate
var StartDateTime = new Date(startDate).getTime();
var endDate = '5/10/2015';
var EndDateTime = new Date(endDate).getTime();
var Now = new Date().getTime();
if(StartDateTime < Now && EndDateTime < Now){    
    alert("Bookings cannot be created for a previous date");
}

