【发布时间】:2012-01-05 17:27:26
【问题描述】:
问题是:
- 我知道如何在 boost 中获取当地时间
代码:
boost::local_time::local_date_time currentTime(
boost::posix_time::second_clock::local_time(),
boost::local_time::time_zone_ptr());
std::cout << currentTime.local_time() << std::endl;
- 我知道如何从机器获取当前时区数据(希望是对的方式)
代码:
tzset();
// the var tzname will have time zone names
// the var timezone will have the current offset
// the var daylight should show me if there is daylight "on"
但我仍然无法使用当前 time_zone 获取 local_date_time...有人知道,该怎么做吗?
【问题讨论】:
-
您有以当地时间打印时间吗?如果您能够使用 UTC,您就可以省去各种麻烦。
-
"您必须以当地时间打印时间吗?"是的,我必须:(
-
“看看日期时间IO教程?”我想你在那里找到了答案?如果是的话,如果你在本教程中展示它,我会很高兴,因为我试图在 boost.org 上找到它(不仅是)2 天
-
:还是我看错了问题?" 看起来我写得不好...我知道如何打印 local_date_time,我不知道如何使用当前日期时间获取 local_date_time和时区
标签: c++ boost timezone boost-date-time