How to find a date day

I want to find the day of the week of a specific date in Qt. For example: 1/05/2010 - Sunday.

Is it possible to find the day of the week using the date?

+5
source share
3 answers
QDate date;
date.setDate(2010,5,1);
int day = date.dayOfWeek();
QString weekDay = QDate::longDayName(day);

This is not verified. But hope it works. Check it out and let me know.

+15
source

int QDate :: dayOfWeek () const

Returns the day of the week (1 to 7) for this date.

For instance,

QDate date;
date.setDate(2010, 5, 1);

switch (date.dayOfWeek()) {
 case 1:
  // Monday
  break;
 // etc...
}
+2
source

I think you need a QDate class and a dayOfWeek function.

int QDate :: dayOfWeek () const

Returns the day of the week (1 to 7) for this date.

+1
source

All Articles