Istudent Rana

Istudent Rana

  • 1.4k
  • 342
  • 84k

How do create Date from time (hh:mm) and bind with Datetime

Feb 25 2020 12:02 AM
In my ASP.Net MVC project I am using the TimePicker plugin to render time.
 
$.ajax({
url: "/payroll/PostPayrollEmpSheet",
type: "POST",
data: {
'ProjectId': $('.counterPayroll').data('projectid'),
'PayrollEmployeeType': 1,
'DayNumber': $('.counterPayroll').data('daynumber'),
'EmployeeName': empName,
'PreBreakClockIn': preBreakTimeClockIn,
'PreBreakClockOut': preBreakTimeClockOut,
'PostBreakClockIn': postBreakTimeClockIn,
'PostBreakClockOut': postBreakTimeClockOut
}
})
 
In my Action method in backend expects DateTime datatype. How do I parse hh:mm time to DateTime and send via AJAX?
 
I tried to do something like this also:
 
'PreBreakClockIn': new Date('1970-01-01T' + preBreakTimeClockIn + 'Z'),
'PreBreakClockOut': new Date('1970-01-01T' + preBreakTimeClockOut + 'Z')

Answers (3)