0

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 ?

1

1 Answer 1

1

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));
Sign up to request clarification or add additional context in comments.

1 Comment

It should be var parsedDate = $.datepicker.parseDate('yy-mm-dd', yourDate.substr(0, 10)); otherwise (using 'yyyy-mm-dd') it will give Error: Missing number at position 4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.