boost日期、时间操作

4560阅读 0评论2013-01-17 aquester
分类:C/C++

#include


boost::posix_time::ptime now = boost::posix_time::from_time_t(time(NULL));

boost::posix_time::to_simple_string(now); // CCYY-mmm-dd hh:mm:ss.fffffff

boost::posix_time::to_iso_string(now); // YYYYMMDDTHHMMSS

boost::posix_time::to_iso_extended_string(now); // YYYY-MM-DDTHH:MM:SS



#include


    void sleep(uint32_t seconds)
    {
        boost::xtime xt;
        boost::xtime_get(&xt, boost::TIME_UTC_);
        xt.sec += seconds;
        boost::thread::sleep(xt); // Sleep for 1 second
    }

上一篇:boost库thread.hpp编译警告honored已修复
下一篇:一键自动往crontab添加条目脚本