The QTime component provides a method to input time.
For handling date and/or time, also check out Quasar Date Utils.
/* * No installation step is necessary. * It gets installed by default by @quasar/app v2+. */
Notice that the model is a String only.
For landscape mode, you can use it along with
$q.screen to make QTime responsive. Example:
:landscape="$q.screen.gt.xs". More info: Quasar Screen Plugin.
The 24 hour format is applied depending on the Quasar Language Pack that you’ve set, but you can also force it, like in the example below.
Clicking on the “Now” button sets time to current user time:
The default model mask is
HH:mm:ss when using
with-seconds prop), however you can use custom masks too.
mask prop tokens can be found at Quasar Utils > Date utils.
Note on SSR
X (timestamps) in the mask may cause hydration errors on the client, because decoding the model String must be done with
new Date() which takes into account the local timezone. As a result, if the server is in a different timezone than the client, then the rendered output of the server will differ than the one on the client so hydration will fail.
Note on persian calendar
When using the persian calendar, the mask for QTime is forced to
with-seconds is specified).
If you want to insert strings into your mask, make sure you escape them by surrounding them with
], otherwise the characters might be interpreted as format tokens.
Using the mask to connect a QDate and QTime to the same model:
Custom ad-hoc locale
If, for some reason, you need to use a custom ad-hoc locale rather than the current Quasar Language Pack that has been set, you can use the
- You can use the
second-optionsprops to limit user selection to certain times.
- Alternatively, for a more in-depth way of limiting options, you can also supply a function (second example below) to
Connecting a QDate and QTime with same model on a QInput:
The following are helpers for QInput
rules props. You can use these for convenience or write the string specifying your custom needs.
Examples: “date”, “time”, “fulltime”.
More info: QInput.
With additional buttons v1.2.8+
You can use the default slot for adding buttons:
Native form submit v1.9+
When dealing with a native form which has an
action and a
method (eg. when using Quasar with ASP.NET controllers), you need to specify the
name property on QTime, otherwise formData will not contain it (if it should):