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 no store utc in timestamptz postgresql
Qt 6.11 is out! See what's new in the release blog

QDatetime no store utc in timestamptz postgresql

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.5k 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.
  • C Offline
    C Offline
    Corveejet
    wrote on last edited by
    #1

    Hi everyone,

    I try to store in my bdd a date with utc like that '2021-06-04 16:40:17.017+02', but everytime i get '2021-06-04 16:28:51.975+00'.

    I use Qt 5.3.
    Below a part of my code

    QDateTime date = QDateTime::currentDateTime();
    date.setTimeSpec(Qt::LocalTime);
    ...
    QSqlQuery query(m_database);
    bool ok = query.prepare("insert into .... (..., date_time, ..) values (...., :date_time, ....)");
    
    query.bindValue(":date_time", date);
    bool ok = query.exec();
    ...
    

    Can you help me ?
    regards,

    JonBJ 1 Reply Last reply
    0
    • C Corveejet

      Hi everyone,

      I try to store in my bdd a date with utc like that '2021-06-04 16:40:17.017+02', but everytime i get '2021-06-04 16:28:51.975+00'.

      I use Qt 5.3.
      Below a part of my code

      QDateTime date = QDateTime::currentDateTime();
      date.setTimeSpec(Qt::LocalTime);
      ...
      QSqlQuery query(m_database);
      bool ok = query.prepare("insert into .... (..., date_time, ..) values (...., :date_time, ....)");
      
      query.bindValue(":date_time", date);
      bool ok = query.exec();
      ...
      

      Can you help me ?
      regards,

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Corveejet said in QDatetime no store utc in timestamptz postgresql:
      Hi and welcome.

      I try to store in my bdd a date with utc like that '2021-06-04 16:40:17.017+02'

      I don't understand: how is that date string ending in +02 UTC? And you send it as a local time anyway.

      i get '2021-06-04 16:28:51.975+00'.

      That ends in +00 so looks like UTC.

      If you are saying you store a date with time 16:40 and get back a date with time 16:28 I don't know how that could happen.

      C 1 Reply Last reply
      0
      • JonBJ JonB

        @Corveejet said in QDatetime no store utc in timestamptz postgresql:
        Hi and welcome.

        I try to store in my bdd a date with utc like that '2021-06-04 16:40:17.017+02'

        I don't understand: how is that date string ending in +02 UTC? And you send it as a local time anyway.

        i get '2021-06-04 16:28:51.975+00'.

        That ends in +00 so looks like UTC.

        If you are saying you store a date with time 16:40 and get back a date with time 16:28 I don't know how that could happen.

        C Offline
        C Offline
        Corveejet
        wrote on last edited by
        #3

        Hi @JonB , thanks to answer me.

        No i want make the offset of utc in hour like postgresql. It's date time+/-offsetUtc in hour

        JonBJ 1 Reply Last reply
        0
        • C Corveejet

          Hi @JonB , thanks to answer me.

          No i want make the offset of utc in hour like postgresql. It's date time+/-offsetUtc in hour

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Corveejet
          The simple answer is I do not know what facilities/statements etc. PostgreSQL does or does not have for storing/retrieving local vs UTC times, and how that interacts with date parameters from/to Qt. But @Christian-Ehrlicher should see this, and he is a fan of PostgreSQL so hopefully he will give you some help soon... :)

          C 1 Reply Last reply
          0
          • JonBJ JonB

            @Corveejet
            The simple answer is I do not know what facilities/statements etc. PostgreSQL does or does not have for storing/retrieving local vs UTC times, and how that interacts with date parameters from/to Qt. But @Christian-Ehrlicher should see this, and he is a fan of PostgreSQL so hopefully he will give you some help soon... :)

            C Offline
            C Offline
            Corveejet
            wrote on last edited by
            #5

            @JonB said in QDatetime no store utc in timestamptz postgresql:

            The simple answer is I do not know what facilities/statements etc. PostgreSQL does or does not have for storing/retrieving local vs UTC times. But @Christian-Ehrlicher should see this, and he is a fan of PostgreSQL so hopefully he will give you some help soon... :)

            Ok, thanks ! ^^

            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              See https://bugreports.qt.io/browse/QTBUG-86450

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              C 1 Reply Last reply
              2
              • Christian EhrlicherC Christian Ehrlicher

                See https://bugreports.qt.io/browse/QTBUG-86450

                C Offline
                C Offline
                Corveejet
                wrote on last edited by
                #7

                @Christian-Ehrlicher

                Too bad... Thanks you guys!

                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