Date range picker field shows invalid date

By aniket96 ·
Tags: Software
I am working on a project developed in .NET MVC where I am facing an issue regarding a daterangepicker functionality. The same functionality works on localhost but not on server where my application is hosted. I am using bootstrap’s daterangepicker class. The date format is same in the controller and the JavaScript. I’ll attach the code of the controller and the JavaScript.

Actual working :
A daterange is selected from the daterangepicker and the remaining fields are filled. After this step, I click on Save button and the details are saved. Once it is saved I can submit it and it gets submitted successfully.

After saving the first time, when I navigate to the same page for modification, the daterangepicker shows invalid date. This works on localhost but not on the production server.

I have communicated with the hosting support team regarding this issue but there is nothing wrong from their end. Please let me know if anyone has faced this issue before.

Controller Code:
if (count == 1)
daterange = r.DateRange.Split('/');
fmdate = daterange[0].Trim();
todate = daterange[1].Trim();
tm.UserId = obj.UserId;
//DateTime fordate = DateTime.ParseExact("05/03/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture);
tm.FromDate = DateTime.ParseExact(fmdate, "dd-MM-yyyy", CultureInfo.InvariantCulture);
tm.EndDate = DateTime.ParseExact(todate, "dd-MM-yyyy", CultureInfo.InvariantCulture);
tm.IsSubmited = false;
tm.IsApproved = false;

JavaScript Code:

"dateLimit": {
"days": 5
"locale": {

"format": "DD-MM-YYYY",
"separator": " / ",
"applyLabel": "Apply",
"cancelLabel": "Cancel",
"fromLabel": "From",
"toLabel": "To",
"customRangeLabel": "Custom",
"weekLabel": "W",

"firstDay": 1
"weekStart": 5,
"showWeekNumbers": true,

1 total post (Page 1 of 1)  
Thread display: Collapse - | Expand +

All Answers

Collapse -

The answer to your question my badboy

by cindy31 In reply to Date range picker field s ...

Subsequent to sparing the first run through, when I explore to a similar page for change, the daterangepicker indicates invalid date. This deals with localhost however not on the generation server.

Back to Software Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums