Datepicker Reactive Form onchange event and also dateformat convert to dd/MM/yyyy

Hi,

I have a odata api and fetch the data into controls.

  1. When i fetch the date format has been change it to yyyy-MM-dd. But inside the ejs-datepicker control i mentioned the date format(dd/MM/yyyy). 
  2. When I change the employment date (for eg: Today) and select the probation month like 3or 4 months. I would like to calculate the probation end date (eg: Today + 4 months).
Kindly help me to solve this 

1 Reply

BC Berly Christopher Syncfusion Team October 28, 2021 03:59 PM UTC

Hi Muthu Kumar, 
  
Greetings from Syncfusion support. 
  
Query 1: 
  
When i fetch the date format has been change it to yyyy-MM-dd. But inside the ejs-datepicker control i mentioned the date format(dd/MM/yyyy).  
  
Response: 
  
We have checked the reported issue but the reported issue does not occurred at our end. So, please share the below requested details that will help us to check and proceed further from our end. 
  
·       Code snippet of component rendering and fetched data 
·       Simple issue replicating sample 
·       System date format settings 
·       Have you applied any locale in the sample? If yes, please share that details too. 
  
Query 2: 
  
When I change the employment date (for eg: Today) and select the probation month like 3or 4 months. I would like to calculate the probation end date (eg: Today + 4 months). 
  
Response: 
  
We have prepared the sample based on the requested requirement and attached it below. 
  
  public onChange(args) { 
    var date1Value = this.dateobj.value; 
    if (date1Value != null) { 
      this.dateobj1.value = this.dateobj1.value 
        ? this.dateobj1.value 
        : new Date(); 
      this.dateobj1.value = new Date( 
        this.dateobj1.value.setMonth( 
          date1Value.getMonth() + parseInt(args.value.split(' ')[0]) 
        ) 
      ); 
    } 
  } 
 
 
  
Regards, 
Berly B.C 


Loader.
Up arrow icon