Formatting the daterange form field

We are using the ASPNET Core DateRangePicker

<ejs-daterangepicker id="daterange" placeholder="Choose a Range" startDate="@Model.DateFrom" endDate="@Model.DateTo" format="@Model.DateFormatString">
</ejs-daterangepicker>

We need to get the value of the date range into the server side controller so we are posting the form that wraps the DateRangePicker. The form value is is sent up with two string values one for the start date and one for the end date. However I cannot see a way of formatting the dates. This means that on the server I run the risk of parsing errors. The dates I am currently receiving are "10/20/2020" and "1/20/2021", trying to get them into a DateTime results in an error.

The format attribute on ejs-daterangepicker only affects the UI rendering not the output. Is there another way? Are the dates always output as "mm/dd/yyyy"?

Thanks



1 Reply 1 reply marked as answer

VS Vignesh Srinivasan Syncfusion Team January 22, 2021 03:46 PM UTC

Hi Pat, 
 
We can able to get the startDate and endDate value in the DateTime format using the value property. Please find the sample below. 
 
 
Screenshot: 
 
 
 
Kindly check the above sample. Please let us know if you need further assistance. 
 
Regards, 
 
Vignesh Srinivasan. 


Marked as answer
Loader.
Up arrow icon