Results 1 to 3 of 3

Thread: Why can I not generate a valid Time_t?

  1. #1
    Join Date
    Apr 2008
    Posts
    73
    Thanks
    11
    Thanked 7 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Why can I not generate a valid Time_t?

    Hi,
    Using something like:
    Qt Code:
    1. qDebug() << QString::number( QDateTime(QDate(11,3,9),QTime(13,59,30).toTime_t() );
    To copy to clipboard, switch view to plain text mode 
    looks nothing like a QDateTime::currentDateTime().toTime_t(), and when trying to convert it back to a QDateTime, does not retrieve the correct information. What am I doing wrong?
    Best Regards,
    Phil Winder
    www.philwinder.com

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Why can I not generate a valid Time_t?

    You want to see the time_t value for 9th March 11 at 13:59:30? You should get a highly negative value as time_t = 0 for 1st Jan 1970, about 1959 years after the date you set.

    I guess you meant:
    Qt Code:
    1. QDate(2009, 3, 11);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    philwinder (11th March 2009)

  4. #3
    Join Date
    Apr 2008
    Posts
    73
    Thanks
    11
    Thanked 7 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why can I not generate a valid Time_t?

    Sorry, slight typo. However, replacing 09 with 2009 worked great. Thanks.
    Best Regards,
    Phil Winder
    www.philwinder.com

Similar Threads

  1. How to Compile VTKDesigner2 with Qt?
    By alfredoaal in forum Newbie
    Replies: 0
    Last Post: 5th September 2008, 05:34

Tags for this Thread

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.