[Solved] QDateTime to PostgreSQL
-
Hi guys,
imagine the following:
I've got a widget to enter a date, a time and an integer value to specify the offset from UTC in hours.
The data set in this widget needs to be saved as a QDateTime and later inserted in a PostgreSQL database column of type "timestamp with timezone".What is the best way to construct this QDateTime object with the specified timezone and later construct an insert statement to be executed by the QSqlQuery? I find the topic of timezones and offsets and stuff pretty complicated and can't get my head around what information regarding the timezone is being saved by QDateTime.
Maybe there's a recommended way for doing this. Any help is highly appreciated!
Tobi
-
Hi,
You can build your QDateTime with this constructor so you be able to set the offset to the value your user wanted.
And do the reverse when needed with offsetFromUtc
Hope it helps