📜  cpp 设置时间 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:57.542000             🧑  作者: Mango

代码示例1
#include 

struct tm time = { 0 };

time.tm_year = Year - 1900;
time.tm_mon  = Month - 1;
time.tm_mday = Day;
time.tm_hour = Hour;
time.tm_min  = Minute;
time.tm_sec  = Second;

if (time.tm_year < 0)
{
    time.tm_year = 0;
}

time_t t = mktime(&time);

if (t != (time_t) -1)
{
    stime(&t);
}