When opening datepicker time2 is being reset to the value of time1. Fixed this bug.