Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append time to JQuery datepicker?

I'm trying to follow this example in order to append the current time to my input when a date is chosen with the datepicker. According to the example, I should just be able to append my time string in the dateFormat option:

$("#entry_date").datepicker({dateFormat: $.datepicker.W3C + date_obj_time}); 

However, in my test (fiddle here), the "M" in "AM" or "PM" is turning into the actual month name. For example, if I specify a date format such as this:

$("#DueDate").datepicker("option", "dateFormat", "mm/dd/yy 9:16 AM" );

I end up with this in my text field:

05/14/2013 9:16 A.May.

Is there a workaround for (or better way to do) this, or am I doing something blatantly wrong?

like image 868
lhan Avatar asked Jan 14 '23 06:01

lhan


1 Answers

You need to escape the M by wrapping it in single quotes.

Updated fiddle.

The API isn't very obvious as doesn't list it as an "escape" sequence but it lists '...' as being interpreted as "literal text".

like image 132
freejosh Avatar answered Jan 21 '23 17:01

freejosh