i have a datetime picker.....
in $(document).ready(function (){........
User clicks a save button, post values back to server:
In my controller........
The string is in the format "Tue Sep 09 2014 12:00:03 GMT-0400 (Eastern Standard Time)".
What am i missing here? Why is this difficult at all? And how to i resolve the problem?
<
input
type
=
"datetime"
id
=
"dateOfService"
name
=
"dateOfService"
style
=
"width:250px;"
/>
in $(document).ready(function (){........
var dateOfService = $("#dateOfService").kendoDateTimePicker({
value: new Date(),
culture: "en-US",
format: "dd/MM/yyyy HH:mm:ss",
parseFormats: ["dd/MM/yyyy HH:mm:ss"]
});
User clicks a save button, post values back to server:
$.post("/Home/CreateJob",
{
dateOfService: new Date($("#dateOfService").data("kendoDateTimePicker").value())
}).success(function (data) {
console.log("success");
}).fail(function (data) {
console.log("fail") ;
});
In my controller........
[HttpPost]
public JsonResult CreateJob(string dateOfService)
{
try
{
DateTime d = Convert.ToDateTime(dateOfService); //can't do this. not recognized as valid date/time
}
catch(Exception e){
}
The string is in the format "Tue Sep 09 2014 12:00:03 GMT-0400 (Eastern Standard Time)".
What am i missing here? Why is this difficult at all? And how to i resolve the problem?