Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unix timestamp
Qt 6.11 is out! See what's new in the release blog

Unix timestamp

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 6.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krag
    wrote on last edited by
    #1

    Hello,

    I am trying to get a current Unix time stamp in my QT application but it outputs a wrong date.

         QDateTime asd;
         uint unixTime = asd.toTime_t();
         qDebug() << unixTime;
    

    It outputs: 4294967295 which is 02/07/2106.
    Why does it output 91 years into the future? How do I make it output the current Unix time stamp?

    1 Reply Last reply
    0
    • hskoglundH Online
      hskoglundH Online
      hskoglund
      wrote on last edited by
      #2

      Hi, try

      QDateTime asd(QDateTime::currentDateTime());
      uint unixTime = asd.toTime_t();
      qDebug() << unixTime;
      
      K 1 Reply Last reply
      1
      • hskoglundH hskoglund

        Hi, try

        QDateTime asd(QDateTime::currentDateTime());
        uint unixTime = asd.toTime_t();
        qDebug() << unixTime;
        
        K Offline
        K Offline
        Krag
        wrote on last edited by
        #3

        @hskoglund This did the trick, thank you.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved