PDA

View Full Version : how to calculate difference b/w two times



dummystories
9th March 2009, 08:57
Hi to all,


I am developing an application where i need to login time and save it in database, when ever admin wants to see when ever i need to display all login users and login time in a table widget.

when ever the user logout i need to save the current time and calculate how many hours he logged in.

Can any one tell how to find difference b/w two times( one is in database and one is current time).

i am waiting for your replies and valuable suggestions.


Regards,

Narasimha Raju. Naidu

wysota
9th March 2009, 13:58
QDateTime has QDateTime::daysTo() and QDateTime::secsTo() methods that you can use. Then you can use QTime::addSecs() to easily convert it to hours, minutes and seconds.