【问题标题】:Datetime of value 0 (as in MySQL) with boost::posix_time带有 boost::posix_time 的值为 0 的日期时间(如 MySQL 中)
【发布时间】:2018-09-12 00:43:44
【问题描述】:

boost::posix_time 中,如何获取值为0 的时间戳(boost::posix_time::ptime)? (作为 0-0-0 0:0:0 MySQL 日期时间)。

【问题讨论】:

    标签: c++ boost


    【解决方案1】:

    这是不可能的。 posix_time::ptime 使用gregorian::date 并根据参考gregorian date

    当前实现支持 1400-Jan-01 到 1400-Jan-01 范围内的日期 9999 年 12 月 31 日。

    所以如果你写得到 ptime 的最小值

      boost::posix_time::ptime pt(boost::posix_time::min_date_time);
      cout << pt << endl; // 1400-Jan-01 00:00:00
    

    您将看到 1400-Jan-01 00:00:00 作为输出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-04
      • 1970-01-01
      • 1970-01-01
      • 2010-11-13
      • 1970-01-01
      • 1970-01-01
      • 2012-12-21
      相关资源
      最近更新 更多