I am passing Date having format('dd/mm/yyyy')
from jquery to C#
using Page Method
. When i pass date 31/07/2014
to PageMethod
, it gives me error 31/07/2014 is not a valid value for DateTime.
Here is my Code..
var dto = {
'StudentList': StudentList,
'StudentFeeList': StudentFeeDetail,
'StartingDate': $('#txtStartingDate').val(),
'ClosingDate': $('#txtEndingDate').val()
};
this DTO
is passed to PageMethod
. I am saving data at this time.
While retrieving Date
from DataBase
i have converted it like this.
convertDate = function (jsonDate) {
var date = new Date(parseInt(jsonDate.substr(6)));
return date.format("dd/mm/yyyy");
},
Any Help.. Thanks.
This is because when converting its taking it as mm/dd/yyyy as per your system date time, whenever you post/convert use Universal format ie YYYY-MM-DD
Using universal format is universally accepted format and will not give any issues when converting IT or TO to any format needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.