c++ - 将本地时间转换为 time_t (C++)

标签 c++ date time localtime time-t

我在 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 the tm structure pointed by timeptr (which may be modified).

关于c++ - 将本地时间转换为 time_t (C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25826846/

相关文章:

c++ - 将 '65280' 从 'int' 缩小到 { } 内的 'short int'

c++ - 片段着色器中的“错误 : sampler arrays indexed with non-constant expressions are forbidden in GLSL 1. 30 及更高版本”

c++ - FlexeLint/PC-lint 警告不考虑 std::string::append 的返回值

php - MySQL:1970 年之前的日期

python - 无法指定扩展模块的目的地,无法添加 python 模块

jQuery : validate date

javascript - 将 jQuery 日期与 Rails 日期进行比较

Java:基本数学错误?

python time.sleep() 延迟以前的命令

c - Arduino 创建延迟函数