Set Format to dd/MM/yyyy

Hi there,

In my change event on the DateRangePicker, the args.startDate and args.endDate are in long date format.

I would like it in dd/MM/yyyy format.

I have tried setting the date format in the DateRangePicker control, but it does not work.

        @Html.EJ().DateRangePicker("DateRange").Value(DateTime.Now.AddDays(-1) + " - " + DateTime.Now).Width("60%").DateFormat("dd/MM/yyyy").ClientSideEvents(e => e.Change("onRangeChange"))

Regards,

Neill

3 Replies

BC Berly Christopher Syncfusion Team December 8, 2017 12:27 PM UTC

Hi Neill, 
Thanks for contacting Syncfusion support. 
We have looked into your query “In my change event on the DateRangePicker, the args.startDate and args.endDate are in long date format. I would like it in dd/MM/yyyy format” and we suggest you to use  ej.format() method in your application to convert the date value as the desired format. Please refer the below code example. 
 
@Html.EJ().DateRangePicker("daterage").DateFormat("dd/MM/yyyy").ClientSideEvents(e => e.Change("onChange")).Width("50%") 
 
<script> 
    function onChange(args) { 
        var startdate = ej.format(args.startDate, args.model.dateFormat, args.model.locale); 
        var enddate = ej.format(args.endDate, args.model.dateFormat, args.model.locale); 
        alert("startDate value is:" + startdate + "  endDate value is:" + enddate); 
    } 
</script> 
 
 
 
For your convenience, we have prepared the sample based on your requirement. Please get the sample from the below link. 
  
Regards, 
Berly B.C 



NE Neill December 8, 2017 02:04 PM UTC

Great, Thanks


BC Berly Christopher Syncfusion Team December 11, 2017 12:03 PM UTC

Hi Neill, 
 
Thanks for the update. 
 
We are glad to hear that the reported issue is resolved at your end. Please, let us know if you need any further assistance. We will be happy to help you. 
 
Regards, 
Berly B.C 


Loader.
Up arrow icon