c ++ read time and date string into a standard

    struct tm *tt;
    struct timeval tv;
    gettimeofday(&tv,NULL);
    tt = localtime(&(tv.tv_sec));

    char cNowTime[64];
    strftime(cNowTime, sizeof(cNowTime), "%Y-%m-%d-%H-%M-%S", tt);
    std::string str_time = cNowTime;
    std::string save_bag_name = "./" + str_time + ".bag";

    std::cout << "cNowTime = " << cNowTime << std::endl;
    std::cout << "save_bag_name = " << save_bag_name << std::endl;

 

Guess you like

Origin blog.csdn.net/chengde6896383/article/details/91383596