I´m using C++ under Linux and I confess that after reading so many posts on the theme I´m litte confused around time_t
, struct
tm
, time
, ctime
and strftime
.
What I need to do is to get the current system date/time, convert it to UTC and store in database. Later on I need to retrieve that date/time and print on screen in a human readable format.
I´m using Oracle (TIMESTAMP
), mySQL (DATETIME
) and Sqlite3 (has no datetime field, stored either on a INT
or a VARCHAR()
).
The most important is that I need to store date/time with current time zone considering the DST time, as when I get back the result I can recover the original time zone of the DST for correct information display.
Something like:
// Get current time
std::time_t now = std::time(0);
// Convert it to Oracle ???
? oracletime = ?;
// Convert it to mySQl ???
? mysqltime = ?;
// store it on Sqlite3
int sqlite3time = now;
// print the time
std::cout << now << std::endl;
What would be the correct conversion steps here ?
Thanks for helping.
Aucun commentaire:
Enregistrer un commentaire