|  | Home · Overviews · Examples |

# QDate Class Reference
[com.trolltech.qt.core module]

The `QDate` class provides date functions. More...

## Detailed Description

The `QDate` class provides date functions.

A `QDate` object contains a calendar date, i.e. year, month, and day numbers, in the Gregorian calendar (Julian calendar for dates before 15 October 1582). It can read the current date from the system clock. It provides functions for comparing dates, and for manipulating dates. For example, it is possible to add and subtract days, months, and years to dates.

A `QDate` object is typically created either by giving the year, month, and day numbers explicitly, or by using the static function `currentDate` that creates a `QDate` object containing the system clock's date. An explicit date can also be set using `setDate`. The `fromString` function returns a `QDate` given a string and a date format which is used to interpret the date within the string.

The `year`, `month`, and `day` functions provide access to the year, month, and day numbers. Also, `dayOfWeek` and `dayOfYear` functions are provided. The same information is provided in textual format by the `toString`, `shortDayName`, `longDayName`, `shortMonthName`, and `longMonthName` functions.

`QDate` provides a full set of operators to compare two `QDate` objects where smaller means earlier, and larger means later.

You can increment (or decrement) a date by a given number of days using `addDays`. Similarly you can use `addMonths` and `addYears`. The `daysTo` function returns the number of days between two dates.

The `daysInMonth` and `daysInYear` functions return how many days there are in this date's month and year, respectively. The `isLeapYear` function indicates whether this date is in a leap year.

Note that the Gregorian calendar was introduced at different dates in different countries and regions. `QDate` uses the Gregorian calendar starting from 15 October 1582, and uses the Julian calendar for dates up to 4 October 1582.

See also `QTime`, `QDateTime`, `QDateEdit`, `QDateTimeEdit`, and `QCalendarWidget`.