0

This is very old question and there are similar topics to this here and here and so on. I have:

  • year like 2014,
  • month like 10,

  • ...
  • seconds like 23.

Using these integers I want to get the unix time (the seconds since 1970. 01. 01.). But finally I want only an integer again. How can I do that?

I can use only STL and QT (not Boost). I know there is QDateTime which can solve this, but I still don't know how.

EDIT1: I tried this one, but it seems something went wrong:

const WCCIL::QDate dd(/*fill it*/);
const WCCIL::QTime tt(/*fill it*/);
WCCIL::QDateTime ddtt( dd, tt); // error, no constructor
ddtt.toUTC();
Community
  • 1
  • 1

1 Answers1

1

The first link you posted (C++ How can I convert a date in year-month-day format to a unix epoch format?) contains the answer you want. You need to use a tm struct with mktime(). See the mktime() man page for more information.

Community
  • 1
  • 1
Rob K
  • 8,757
  • 2
  • 32
  • 36