I need to convert my string to a date format to pass it in a way that my mvc c# understands it.
Please read the following, where I explain the problem step by step.
I have an input
<input name="EgresoStJohns" class="form-control txtOut"/>
When the user saves the form, I do the following in Jquery
var dateOut = $(".txtOut").val();
dateOut becomes something like this, depending on the date that the user picks: 30/03/2017
Then I try to parse my date, so the controller in c# mvc understands that I want to send a dd/mm/yy, otherwise, if I send 30/03/2017 the controller will understand month=30 and it will conver the entire date to null.
var DateToSend = new Date(parseInt(dateOut));
DateToSend = DateToSend.getDate() + "/" + (DateToSend.getMonth() + 1) + "/" + DateToSend.getFullYear();
However, inmmediately after doing the New Date, the input ALWAYS becomes "31/12/1969", so I am unable to work with it.
What can I do to solve this inconvenience?
dateOuttoparseInt()?parseInt(dateOut)return30- you would need to split the value based on/to get the componentsdd/MM/yyyyformat, or to create a custom ModelBinder for dates