服务端统一时间戳 boost::date_time UTC
生活随笔
收集整理的這篇文章主要介紹了
服务端统一时间戳 boost::date_time UTC
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
多服務器在多時區部署時, 需要按utc時間統一計算。
可以使用boost::date_time
#include <boost/date_time.hpp> #include <iostream> #include <string> using namespace std; using namespace boost; using namespace boost::gregorian; using namespace boost::posix_time;int main(int, char *[]) {ptime ct2(second_clock::universal_time()); //輸出的就是UTC時間。 如果是使用second_clock::local_time()構造, 得到的就是localtimecout << to_simple_string(ct2) << endl;return 0; }無需其他庫、或者自己寫的程序, 太易出錯了
總結
以上是生活随笔為你收集整理的服务端统一时间戳 boost::date_time UTC的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: boost::asio ssl
- 下一篇: boost shared_ptr线程安全