Boost 获取系统时间格式化字符串

发布时间:2020-07-31 09:04:29 作者:fengyuzaitu
来源:网络 阅读:418

头文件

#include <boost/date_time/posix_time/posix_time.hpp>


代码

 std::string strDateTime = boost::posix_time::to_simple_string(boost::posix_time::microsec_clock::local_time());

结果:2020-Jan-07 02:54:29.985437


 std::string strTime = boost::posix_time::to_iso_string(boost::posix_time::microsec_clock::local_time());
 strTime.insert(4, "-");
 strTime.insert(7, "-");
 int pos = strTime.find('T');
 strTime.replace(pos, 1, std::string(" "));
 strTime.insert(13, ":");
 strTime.insert(16, ":");

 结果:2020-01-07 10:54:29.976652

推荐阅读:
  1. Boost怎么获取系统时间并格式化字符串
  2. 7 C++ Boost 序列化

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

boost posix_time st bo

上一篇:Python3爬虫如何维护代理池

下一篇:什么是C#泛型的类型参数约束

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》