0

I am having problems with something that should be trivial. I have a web api that returns dates in the following format:

2014-01-06T09:46:12.7819007+01:00

If I am not mistaking, this is a very common iso format. When I feed it to the jQuery datepicker it interprets this date as 7323-10-27. The problem seems to be the time segment of the date.

This: 2014-01-06T09:46:12.7819007+01:00 Gets parsed as: 7323-10-27

This: 2014-01-06T09:45:35 Gets parsed as: 2019-10-03

This: 2014-01-06T09:45:35 Gets parsed as: 2019-08-29

This: 2014-01-06 Gets parsed, not surprisingly, as: 2014-01-06

So how do I tell the datepicker to ignore the time part of the date? I tried fiddling with the dateFormat option to no avail.

0

1 Answer 1

1

Try converting that string to an actual Date and give that to the datepicker:

var defaultDate = new Date('2014-01-06T09:46:12.7819007+01:00');

When supplying the date as a string it need to match the dateFormat parameter, but creating a format for that in JS will be a headache that's best avoided.

Sign up to request clarification or add additional context in comments.

Comments

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.