Javascript Validate Date&Time
<p>Ive got a piece of JS that needs to validate and compare a start date and time against an end date and time.</p>

<p>So in other words end date &amp; time cannot be less than start date and time.</p>

<p>Now the problem.
I originally only accepted the time in 24 hour(military) Format. but now let the user choose between 12 hour or 24 hour.</p>

<p>Example 13:00 or 1:00 PM</p>

<p>This piece of code work for 24 hour time format, but not for 12, its 12:00 PM that causes the problem.</p>

<p>So I need to adapt this piece of code to work for either 12 hour or 24 hour, but im not sure how to do this.</p>

<pre><code>function validateStartEndTime() {
        var date = document.getElementById("datepickerStart").value;

        var dateEnd = document.getElementById("datepickerEnd").value;

        if (!isValidDate(date)) {
            alert("Not Valid Date");
            return false;
        }
        var start = document.getElementById("timepicker").value;
        var end = document.getElementById("timepickerEnd").value;

        var stDate = new Date(parse(date +" "+ start));
        var enDate = new Date(parse(dateEnd + " "+ end));
        var compDate = enDate - stDate;
        if (compDate &gt;= 0)
            return true;
        else {
            alert("End time must be greater than Start Time ");
            return false;
        }

    }
</code></pre>
