Solved QDatetime no store utc in timestamptz postgresql
-
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 codeQDateTime 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, -
@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 time16:28
I don't know how that could happen. -
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
-
@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... :) -
@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 ! ^^
-
-
Too bad... Thanks you guys!