Results 1 to 2 of 2

Thread: How to get seconds diferences between two datetime

  1. #1
    Join Date
    Mar 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to get seconds diferences between two datetime

    Hello, i want to get the difference between two datetimes values,
    are there any function in datetime class?

    example:
    QDateTime firstDateTime;
    QDateTime lastDateTime;

    int seconds=int.Parse(lastDateTime - firstDateTime);

    Thanks.
    Regards.

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to get seconds diferences between two datetime

    Try this:

    QDateTime firstDateTime;
    QDateTime lastDateTime;
    int seconds = lastDateTime.toTime_t() - firstDateTime.toTime_t();

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.