使用QT中<QDate>。

 

 

1 QDate birthday(2010,10,13);
2 QDate today;
3 today = QDate::currentDate ();
4 int daysold = birthday.daysTo (today);
5 ui->lcdNumber_2->display (daysold);

 

说明:

int QDate::daysTo ( const QDate & d ) const

Returns the number of days from this date to d (which is negative if d is earlier than this date).

 QDate d1(1995, 5, 17);  // May 17, 1995 
 QDate d2(1995, 5, 20);  // May 20, 1995 
 d1.daysTo(d2);          // returns 3 
 d2.daysTo(d1);          // returns -3

相关文章:

  • 2022-12-23
  • 2021-06-15
  • 2021-11-16
  • 2022-12-23
  • 2021-11-30
  • 2021-09-23
  • 2021-05-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-11-30
  • 2021-11-30
相关资源
相似解决方案