I am using datetimepicker tool and getting dates from it into text fields. I have two dates I have to compare these two dates, which are in the text field and have to return difference of dates and alert message if start date is greater than end date and all...
Here I am getting error saying; startdate.getTime is not a valid function. Can anyone help me out how to retrieve the Textfield value as Date object
The proper way is to do:
var date1 = new Date(document.formName.elementName.value);
The date constructor only accepts certain formats. They are
Date() - Used for current date or create an instance of the date object Date(dateString) - Sepcify a Date/ String format is "month day, year hours:minutes:seconds" or "MM/DD/YY HH:MM:SS". Date(year, month, day, hours, minutes, seconds) - Create an instance of date with the specified values. Can be just (year, month, date)