Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How to get UTC date and time as y,M,d,h,m,s integers?

    General and Desktop
    2
    3
    153
    Loading More Posts
    • 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.
    • M
      mireiner last edited by mireiner

      Hi there,

      in QDateTime I was only able to get date and time in QString format yet. But struggle to get integer formated values.

      What is generally the simplest way to get UTC date and time in Qt in integer format like:

      int year = 2020;
      int month = 7;
      int day = 30;
      int hour = 10;
      int minutes = 18;
      int seconds = 12;

      Best regards,
      mireiner

      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @mireiner last edited by

        @mireiner

        QDateTime dt(QDateTime::currentDateTime());
        qDebug() << dt.date().year() << dt.date().month() << dt.date().day() << dt.time().hour() << dt.time().minute() << dt.time().second();
        

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        M 1 Reply Last reply Reply Quote 2
        • J.Hilk
          J.Hilk Moderators @mireiner last edited by

          @mireiner

          QDateTime dt(QDateTime::currentDateTime());
          qDebug() << dt.date().year() << dt.date().month() << dt.date().day() << dt.time().hour() << dt.time().minute() << dt.time().second();
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

          Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          M 1 Reply Last reply Reply Quote 2
          • M
            mireiner @J.Hilk last edited by

            Hello J.Hilk,

            that was fast and helped alot.

            Thank you very much!

            1 Reply Last reply Reply Quote 1
            • First post
              Last post