JSFiddle - React, Tailwind, and code Playground
by rjurd
HTML
<div id='car_eventDate_from'>18-Sep-2013</div>
<div id='car_eventDate_return'>15-Oct-2013</div>
<div id='result'></div>
JavaScript
var date_from = customParse(document.getElementById('car_eventDate_from').innerHTML);
var date_return = customParse(document.getElementById('car_eventDate_return').innerHTML);
if(date_from >= date_return)
{
document.getElementById('result').innerHTML = 'from is greater';
}
else {
document.getElementById('result').innerHTML = 'return is greater';
}
function customParse(str) {
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
n = months.length,
re = /(\d{2})-([a-z]{3})-(\d{4})/i,
matches;
while (n--) {
months[months[n]] = n;
} // map month names to their index :)
matches = str.match(re); // extract date parts from string
return new Date(matches[3], months[matches[2]], matches[1]);
}