Results 1 to 3 of 3

Thread: Difference between two DateTime object

  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Difference between two DateTime object

    Hi,
    I am looking for a function which gives me the difference between two DateTime objects. in hour or minutes.
    OR
    Just give me the difference between them in seconds.
    Always Believe in Urself
    Merry

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Difference between two DateTime object


  3. #3
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Difference between two DateTime object

    Actually i want to calculate the difference between current time and the UTC time ,
    i use the following code for that.........
    QDateTime firstDateTime = QDateTime::currentDateTime();
    QDateTime lastDateTime = QDateTime::currentDateTime().toUTC();
    QString o_r = firstDateTime.toString("yyyyMMddhhmmss");
    QString p_r = lastDateTime.toString("yyyyMMddhhmmss");
    seconds = firstDateTime.toTime_t() - lastDateTime.toTime_t();
    // seconds = firstDateTime.secsTo(lastDateTime);



    But seconds like this comes as 0 .Because both the times are converted to UTC before the calculation,and hence trhe result.
    My concern how to find the difference between current time and UTC time.
    Always Believe in Urself
    Merry

Similar Threads

  1. SQLite DATETIME fieldtype
    By phildu44 in forum Qt Programming
    Replies: 5
    Last Post: 30th December 2009, 07:38
  2. bindValue string to datetime db field
    By pmlody in forum Qt Programming
    Replies: 0
    Last Post: 19th September 2009, 09:48
  3. How to get seconds diferences between two datetime
    By gustavedgardo in forum Newbie
    Replies: 1
    Last Post: 4th March 2009, 22:05
  4. How to change system DateTime?
    By FreePascal in forum Qt Programming
    Replies: 8
    Last Post: 5th April 2008, 14:50
  5. Replies: 1
    Last Post: 30th June 2006, 05:24

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.