cpp set time

Solutions on MaxInterview for cpp set time by the best coders in the world

showing results for - "cpp set time"
Tommaso
26 Nov 2018
1#include <time.h>
2
3struct tm time = { 0 };
4
5time.tm_year = Year - 1900;
6time.tm_mon  = Month - 1;
7time.tm_mday = Day;
8time.tm_hour = Hour;
9time.tm_min  = Minute;
10time.tm_sec  = Second;
11
12if (time.tm_year < 0)
13{
14    time.tm_year = 0;
15}
16
17time_t t = mktime(&time);
18
19if (t != (time_t) -1)
20{
21    stime(&t);
22}
23