struct tm tm_time; strptime(time.c_str(), "%Y%m%d %H:%M:%S", &tm_time); time_t tt = mktime(&tm_time);
mktime() python time模块也有这个函数。
------------------------
char buffer[128];
time_t now = time(NULL);
struct tm *timeinfo = localtime(&now);
strftime(buffer, sizeof(buffer), "%Y-", timeinfo);
printf("year=%s ", buffer);
std::string year(buffer);
std::string str_time = year + what[1];
struct tm tm_time;
strptime(str_time.c_str(), "%Y-%m-%d %H:%M:%S", &tm_time);
time_t tt = mktime(&tm_time);