- Qt 6.4
- Qt QML
- QML Types
- date
- Qt 6.4.3 Reference Documentation

# date QML Value Type

a date value. More...

## Detailed Description

The `date` type refers to a date value, including the time of the day.

To create a `date` value, specify it as a "YYYY-MM-DDThh:mm:ss.zzzZ" string. (The T is literal, YYYY is a full year number, MM and DD are month and day numbers, hh, mm and ss are hours, minutes and seconds, with .zzz as milliseconds and Z as time-zone offset. The T and following time are optional. If they are omitted, the date is handled as the start of UTC's day, which falls on other dates in some time-zones. When T is included, the :ss.zzz or just .zzz part can be omitted. With or without those, the zone offset can be omitted, in which case local time is used.) For example:

     MyDatePicker { minDate: "2000-01-01 0:0"; maxDate: "2020-12-31 23:59" }

To read a date value returned from a C++ extension class, use Qt.formatDate() and Qt.formatDateTime().

When integrating with C++, note that any QDate or QDateTime value passed into QML from C++ is automatically converted into a `date` value, and vice-versa. Note, however, that converting a QDate will result in UTC's start of the day, which falls on a different date in some other time-zones. It is usually more robust to convert the QDate via a QDateTime explicitly, specifying local-time or a relevant time-zone and selecting a time of day (such as noon) that reliably exists (daylight-savings transitions skip an hour, near one end or the other of a day).

This value type is provided by the QML language. It can be implicitly converted to a Date object.

See also QML Date object and QML Value Types.