You haven't supplied sufficient information to answer the question precisely, so only general advice can be given.
Input type date isn't supported by all browsers in use, so simply converting whatever the user inputs to a date object without first validating the input will not be a robust solution.
Consider a British user with settings for dates in the format dd/mm/yyyy who enters 23/11/2015. This value is then parsed using the Date constructor.
In Chrome (which supports date inputs), the input will provide a hint of dd/mm/yyyy based on system settings. The value returned by the input's value property will be a string of 2015-11-23, which will be parsed by the Date constructor in Chrome as a local date.
In Firefox v42, which doesn't support Date inputs, the string will be returned exactly as entered by the user. Firefox will parse 23/11/2015 as if it was mm/dd/yyyy and return a date for 11/11/2016.
Safari 9 also doesn't support date inputs and will try to parse it as mm/dd/yyyy like Firefox, but will return an invalid date (since there is no month 23).
Omniweb 6 acts like Safari.
So the statement that "it doesn't work" is not surprising. For a robust date input, you will have to:
- Specify the format that users should enter
- Validate that the value entered is a valid date
- Compare the values
If valid strings are entered, they can be compared for equality directly, there is no need to convert them to Date objects. However, if date objects are required later, there's no harm in comparing dates if they are converted to numbers, e.g.
if (+date0 == + date1) {
// Dates are equal
}
The dates must be converted to number first as otherwise == will compare them as objects, and no two objects are ever equal so the result will always be false unless d0 and d1 reference the same date object (which, given comments on the OP, seems to be the problem, in Chrome at least).
datetimevalidationdocument.getElementById("mydateL").value? Parsing strings with the Date constructor is strongly advised against, there's a good chance that both leavedate and arrivedate are NaN in some or all browsers.