Start time, end time and time steps
It may not be useful for your customers to be able to select any time of the day. Maybe you're creating a pizza delivery form. Maybe you have a clowns for hire service. Maybe you're offering pizzas delivered by clowns. Regardless, you'll only want to deliver during your operating hours.
You can set the beginning and end time range in the drop down menu by setting data-start
and data-end
. Let's also presume you only want your customers to be able to choose from half hour blocks by setting data-step="30"
.
Time formats
timepicker.js doesn't mind too much what time format you use to set this time. For example, 5pm could be written as "5:00pm"
, "5pm"
or "17:00"
, regardless of your formatting options.
Steps (time blocks) format
Steps must be specified in minutes. For example data-step="15"
would be 15 minute blocks (default), data-step="30"
for half hour blocks and data-step="60"
for one hour blocks.
Example
When shoud I use 24-hour time? What's wrong with the 12-hour format?
These days, 24-hour time is only really used where the ambiguity of 12-hour time can cause problems.
In the example above, would 12am mean your plane leaves first thing tomorrow, or last?
Although most people in the world use 12-hour time, if you really think about it, the 12-hour format is quite stupid:
-
AM rolls over to PM at midday/noon, then the 12 rolls back to 1 an hour later.
12-hour time gives us
10am →
11am →
12pm →
1pm →
2pm
The first hour of the day is actually 12, not 1. I'll let you think about that.
Does "midnight last Tuesday" or even "12am last Tuesday" mean the very beginning or end of tuesday?
24-hour time has both 00:00 and 24:00 to express the difference.
The time is exactly the same, but it clarifys things in the context of a single day. For example "00:00 last tuesday" would be the beginning of the day, and "24:00 last tuesday" would be the end.
What next?
That's it! pretty simple huh?
As you already know, form follows function, so it's time for styling your timepickers.