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. QDateTime Troubles.
Qt 6.11 is out! See what's new in the release blog

QDateTime Troubles.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.8k Views 2 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.
  • giuseppe micheliG Offline
    giuseppe micheliG Offline
    giuseppe micheli
    wrote on last edited by
    #1

    Hello,
    I found out some problems in using the QDateTime class within the simplest code (a form, a button, some further line codes for test).
    I'm running my QT Creator 3.3.0 (Qt 5.4.0) under Windows 10 and I couldn't try the same code under other operating systems yet.
    I got my first strange results in trying to extract some file data through the QFileInfo class: all the QDateTime results (i.e. lastModified,lastRead,created methods on an existing file) gives me the starting time "Jenuary 1st 1970, 00:00:00".
    I tried to use the QDateTime class directly, having the same results:

    QDateTime theCurrentDateTime = QDateTime::currentDateTime();
    QDateTime theCurrentDTUTC = QDateTime::currentDateTimeUtc();
    

    both are set to the same Jenuary the 1st 1970 at midnight!

    I also tried the QDate and QTime classes that gave me the expected result:

    QDate theCurrentDate = QDate::currentDate();
    QTime theCurrentTime = QTime::currentTime();
    

    Thanx for paying me attention, hope this could be useful.
    Yours,
    Giuseppe Micheli.

    raven-worxR Paul ColbyP 2 Replies Last reply
    0
    • giuseppe micheliG giuseppe micheli

      Hello,
      I found out some problems in using the QDateTime class within the simplest code (a form, a button, some further line codes for test).
      I'm running my QT Creator 3.3.0 (Qt 5.4.0) under Windows 10 and I couldn't try the same code under other operating systems yet.
      I got my first strange results in trying to extract some file data through the QFileInfo class: all the QDateTime results (i.e. lastModified,lastRead,created methods on an existing file) gives me the starting time "Jenuary 1st 1970, 00:00:00".
      I tried to use the QDateTime class directly, having the same results:

      QDateTime theCurrentDateTime = QDateTime::currentDateTime();
      QDateTime theCurrentDTUTC = QDateTime::currentDateTimeUtc();
      

      both are set to the same Jenuary the 1st 1970 at midnight!

      I also tried the QDate and QTime classes that gave me the expected result:

      QDate theCurrentDate = QDate::currentDate();
      QTime theCurrentTime = QTime::currentTime();
      

      Thanx for paying me attention, hope this could be useful.
      Yours,
      Giuseppe Micheli.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @giuseppe-micheli
      can you retry with the latest Qt version?
      Have you compiled Qt yourself? If no, i suspect a Qt bug...

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • giuseppe micheliG giuseppe micheli

        Hello,
        I found out some problems in using the QDateTime class within the simplest code (a form, a button, some further line codes for test).
        I'm running my QT Creator 3.3.0 (Qt 5.4.0) under Windows 10 and I couldn't try the same code under other operating systems yet.
        I got my first strange results in trying to extract some file data through the QFileInfo class: all the QDateTime results (i.e. lastModified,lastRead,created methods on an existing file) gives me the starting time "Jenuary 1st 1970, 00:00:00".
        I tried to use the QDateTime class directly, having the same results:

        QDateTime theCurrentDateTime = QDateTime::currentDateTime();
        QDateTime theCurrentDTUTC = QDateTime::currentDateTimeUtc();
        

        both are set to the same Jenuary the 1st 1970 at midnight!

        I also tried the QDate and QTime classes that gave me the expected result:

        QDate theCurrentDate = QDate::currentDate();
        QTime theCurrentTime = QTime::currentTime();
        

        Thanx for paying me attention, hope this could be useful.
        Yours,
        Giuseppe Micheli.

        Paul ColbyP Offline
        Paul ColbyP Offline
        Paul Colby
        wrote on last edited by
        #3

        Hi @giuseppe-micheli, and welcome :)

        That does sound like an odd problem, possibly specific to the machine you're on.

        Out of curiosity, how are you checking the value of the QDateTime? What does it show if you simply stream the QDateTime to qDebug like:

        const QDateTime theCurrentDTUTC = QDateTime::currentDateTimeUtc();
        qDebug() << theCurrentDTUTC;
        
        1 Reply Last reply
        0
        • giuseppe micheliG Offline
          giuseppe micheliG Offline
          giuseppe micheli
          wrote on last edited by
          #4

          Hi mates.
          First of all thank u a lot for your immediate replies.
          I updated my Qt environment to the 3.5.1 version for Qt Creator (based on Qt 5.5.1) and the problem has been solved.
          Paul, I debugged the call to the (static) currentDateTimeUtc using the creator internal debugger and having the same troubles; I have the old version still on my PC, so, if you wanna me to make any further attempts feel free to ask me.
          Thank you very much again.
          Yours,
          Giuseppe

          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