Display 12, read/write 24 TimePicker jQuery plugin

Wednesday, 30 December 2009 @ 17:47

Jason Huck’s jQuery TimePicker plugin didn’t work for me as-is since it reads and writes in 12-hour format. While most people (strangely) prefer 12 hour format for interacting with, database time fields are 24 hour. I could have converted the format with scripting on the back-end but decided I would prefer to have the picker display 12-hour but read/write 24-hour. So, I took Jason’s great design and rewrote it to suite my needs.

Other changes I made were adding a colon between the hour and the minute select lists, adding a space between the minute and the am/pm list, and changed the hours and minutes arrays such that the hours no longer have leading zeros and the minutes are every five instead of every fifteen.

I have intergrated tomsalfield (issue 3) and jasonalanharris’ (issue 5) changes as well.

My version of the script can be found in the issue tracker on the Google Code project for the plugin. Here’s a screenshot of it in use next to a date field:

respond to post

You must be logged in to post a comment.

pages

categories

events

syndication

random members

Utah PHP Users Group

recent posts

recent comments

recent job announcements

search

C7 Data Centerscolocated at C7 Data Centers
administered by Anavi Design