Reputation: 131
I am using jQuery ajax to call a Web API service. The response is Json something like this
{"Id":2,"UserName":"[email protected]","CreatedDate":"2013-01-17T12:40:26.043","ExpireDate":"2023-01-17T12:40:26.043"}]
The question is: how do I bind the Createddate and Expiredate to jQuery DatePicker fields without time? So basically I need to set the value of the datepicker field something like: yyyy-mm-dd. The problem is how to parse this datetime format 2013-01-17T12:40:26.043 that will return just the yyyy-mm-dd ?
Upvotes: 0
Views: 498
Reputation: 332
You can parse it simply doing this :
var yourDate = '2013-01-17T12:40:26.043';
var parsedDate = $.datepicker.parseDate('yyyy-mm-dd', yourDate.substr(0, 10));
Upvotes: 1