2

I creating date() function on C++ http://aliarth.lt/date.cpp and I got one problem with localtome_to_time() conversion. Does anyone know how that local_time variable:

int time_integer = 12345;
time_t time = (time_t)time_integer;

tm *local_time = localtime(&time);
local_time->tm_year = 100;
local_time->tm_mon = 10;
local_time->tm_mday = 1;

Convert to time_t?

Lkopo
  • 4,798
  • 8
  • 35
  • 60
Alivat
  • 51
  • 9

1 Answers1

3

Try mktime, here is its signature:

time_t mktime (struct tm * timeptr);

Returns the value of type time_t that represents the local time described by the tm structure pointed by timeptr (which may be modified).

Piotr Skotnicki
  • 46,953
  • 7
  • 118
  • 160
Peter Pei Guo
  • 7,770
  • 18
  • 35
  • 54