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. How to get UTC date and time as y,M,d,h,m,s integers?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 947 Views 1 Watching
  • 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 Offline
    M Offline
    mireiner
    wrote on last edited by mireiner
    #1

    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.HilkJ 1 Reply Last reply
    0
    • M 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.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @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


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

      M 1 Reply Last reply
      2
      • J.HilkJ J.Hilk

        @mireiner

        QDateTime dt(QDateTime::currentDateTime());
        qDebug() << dt.date().year() << dt.date().month() << dt.date().day() << dt.time().hour() << dt.time().minute() << dt.time().second();
        
        M Offline
        M Offline
        mireiner
        wrote on last edited by
        #3

        Hello J.Hilk,

        that was fast and helped alot.

        Thank you very much!

        1 Reply Last reply
        1

        • Login

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