c++ 时间格式化

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);
上一篇:MySQL数据库 | 数据表的增删改查


下一篇:SQL Server使用规范(转)