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\n", 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);






 

相关文章:

  • 2021-07-15
  • 2022-02-17
  • 2022-01-08
  • 2022-03-04
  • 2021-08-23
猜你喜欢
  • 2021-08-17
  • 2021-06-23
  • 2021-11-14
  • 2022-12-23
  • 2021-12-03
  • 2021-07-20
相关资源
相似解决方案