我在 C++ 上创建 date() 函数 http://aliarth.lt/date.cpp我在 localtome_to_time()
转换方面遇到了一个问题。有谁知道 local_time 变量如何:
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;
转换为time_t
?
最佳答案
尝试mktime
,这是它的签名:
time_t mktime (struct tm * timeptr);
Returns the value of type
time_t
that represents the local time described by thetm
structure pointed bytimeptr
(which may be modified).
关于c++ - 将本地时间转换为 time_t (C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25826846/