boost_处理时间
来源:互联网 发布:计算机算法书籍推荐 编辑:程序博客网 时间:2024/06/08 06:05
Boost 时间处理
1、 引入的库文件
要使用C++boost 中的时间处理函数需要引入库
target_link_libraries(saveParm boost_date_time)
2、 需要引用的头文件及命名空间为
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
using namespace boost::gregorian;
using namespace boost::posix_time;
#define BOOST_DATE_TIME_SOURCE
3、 获得当前时间
ptime now = second_clock::local_time();
根据 ptime 得到时间:
date currentDay=now.date();
4、 从字符串中生成日期
date tempDate=from_string(“2016/12/09”);
5、 从时间戳中生成时间
ptime tempTime=from_time_t(1479826676);
6、 得到当前的星期
int weekday=currentDay.day_of_week();
7、 得到当前的小时
int currentHour=now.time_of_day().hours();
0 0
- boost_处理时间
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- 时间处理
- Qt 模态对话框与非模态对话框及生命周期
- iOS沙盒文件存储
- Spring+SpringMVC+Redis
- RadioButton和HorizontalScrollView实现分类标签
- (POJ2777)Count Color <经典:线段树区间修改 + 或运算记颜色数>
- boost_处理时间
- 线程安全性问题
- 下行资源分配类型
- linux内核list.h
- PAT 1096 Consecutive Factors (暴力,最大连续乘积)
- chown命令--Linux命令应用大词典729个命令解读
- 利用JDBC连接Oracle数据库
- Ubuntu下进行真机调试
- 十五周—判断 字符回文