String is interpreted as a date

I am trying to pass a string parameter from Javascript to a controller method in a .NET MVC program and interpret it as a date somewhere along the way and reformat it. I want him to stop, or at least get it right.

I have this line in a Javascript file:

window.open(viewUrl + "?fromDate=" + fromDates[pointIndex] + "&toDate=" + toDates[pointIndex] 

The firebug breakpoint tells me that I have this:

fromDates [pointIndex]

But when it hits the controller, it looks like this:

enter image description here

It would be good and good if it had not changed from October 1 to January 10 at some point between them. I cannot rely on browser settings because it can be used in a number of countries / cultures, and it does the same if the fromdates[pointIndex] value is of the form YYYY-MM-DD .

How can I make it stop reformatting the string and just pass it as it is in the Javascript array?

+4
source share
1 answer

The date does not change from October 1 to January 10, but the format changes from "dd / MMM / yyyy" to "MM / DD / YYYY"

Try

 fromDates[pointIndex].toString() toDates[pointIndex].toString() 

Or you can use the library as a moment to transfer it in a specific format

0
source

All Articles