C++11 生成當前時間戳

//需要加的頭文件
#include <chrono>
#include <sstream>

        std::chrono::time_point<std::chrono::high_resolution_clock> now = 		std::chrono::high_resolution_clock::now();
        long long tmp = now.time_since_epoch().count();
        std::ostringstream os;
        os << tmp;
        std::string result;
        std::istringstream is(os.str());
        is >> result;
        //_ltoa_s(tmp, buffer, size, 10);
        std::string consumerTag = "TempConsumer" + result;
        std::cout << "consumerTag: " << consumerTag << std::endl;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章