Reputation: 6441
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.
Upvotes: 0
Views: 155
Reputation: 337570
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.
Upvotes: 1