Mandar Shinde

Mandar Shinde

  • NA
  • 423
  • 109.4k

How to pass date and time from angular 5 to asp .net mvc 5

Mar 16 2019 12:52 AM
Hi..
I am new on this technology.
I am Building an application using angular 5 and asp .net 5.
I am trying to save current date and time in mysql database from fornt end which is angular. I have taken datepicker in angular html.
when i am sending date and time from datepicker to asp .net controller. 
Here while debugging we found that Date is coming correctly but time is mismach.
 
Here is my Angular Html code,
  1. <div class="col-md-3 pr-1">  
  2.                     <div class="form-group ">  
  3.                       <label>Date Time</label>  
  4.                       <ejs-datetimepicker id='datepicker' class="form-control" placeholder='Select a date'   
  5.                         format='dd/MM/yyyy hh:mm a' [min]='minDate'  [(ngModel)]="itemToEdit.AppDateTime"  
  6.                         name="AppDateTime">  
  7.                       </ejs-datetimepicker>  
  8.                 </div>  
 Here is my Angular ts code,
  1. saveAppointment() {  
  2.   
  3.    this.isInProgress = true;  
  4.      
  5.    this.appointmentService.SaveAppointment(this.itemToEdit).subscribe(data => {  
  6.      this.loadAppointment();  
  7.      alert(this.messages['msg_Success']);  
  8.   
  9.      this.isInProgress = false;  
  10.    });  
  11.  }  
Here is my Api code,
  1. public void Post([FromBody]Appointment value)  
  2.        {  
  3.            _AppointmentRepository.Post(value);  
  4.        }  
In above code i.e. web api code we are recieving correct date but wrong time.
 
thank you in advance 
 
 

Answers (2)