问题描述
是否有一些标准"的方法,或者我能做的最好的方法是通过从 gregorian::date(1970,1,1) 中减去来直接计算它?
time_t 是用于以秒为单位(通常是纪元时间)保持时间的类型.我猜你是在纪元时间之后,如果是这样的话,除了你已经进行的减法之外,我不知道有任何方法可以直接获得纪元时间.一旦你有了 time_duration(减法的结果),你就可以在持续时间上调用 total_seconds() 并将其存储在 time_t 中.>
顺便说一句.如果你在时代之后,你可以简单地使用 gettimeofday() 并为自己省去一些麻烦!
Is there some "standard" way or the best I can do is to compute it directly by subtracting from gregorian::date(1970,1,1)?
time_t is the type used to hold time in seconds (typically epoch time). I'm guessing you are after epoch time, if so I'm not aware of any way in boost of actually getting epoch time directly, aside from the subtraction you have already. Once you have a time_duration (result of the subtraction), you can call total_seconds() on the duration and store that in time_t.
btw. if you are after epoch time, you could simple use gettimeofday() and save yourself some headache!
这篇关于如何将 boost::posix_time::ptime 转换为 time_t?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)