trentrichardson / jQuery-Timepicker-Addon

Adds a timepicker to jQueryUI Datepicker
http://trentrichardson.com/examples/timepicker/
MIT License
2.66k stars 1.05k forks source link

Unable to parse date and time #831

Open sprakashg opened 8 years ago

sprakashg commented 8 years ago

In my $http.get call I get the date in this 2015-03-08T10:25:00.000Z format. How can I set this back to normal yy-mm-dd hh mm format.

Error parsing the date string: Extra/unparsed characters found in date: T10:25:00.000Z date string = 2015-03-08T10:25:00.000Z date format = yy-mm-dd timeticker.js:2209 Error parsing the date/time string: Extra/unparsed characters found in date: T10:25:00.000Z date/time string = 2015-03-08T10:25:00.000Z timeFormat = hh:mm tt dateFormat = yy-mm-dd

trentrichardson commented 8 years ago

The format must match what timepicker expects or it will not be able to parse it (I think you have established that much already..)

There are a few ways to go about this. Timepicker provides some utility methods that may help with this:

$.datepicker.parseTime() and $.datepicker.formatTime(). Have a look at the documentation for usage example.

Outside of that you can use some string method to pick apart your datetime.