从提升日期获取年份作为字符串

Ron*_*oss 0 c++ boost date

我正在使用boost的日期对象我想从这个对象获取年份字符串或int

我没有找到这样做的简单方法谢谢!罗恩

not*_*row 5

#include <boost/date_time/local_time/local_time.hpp>
#include <boost/lexical_cast.hpp>
#include <string>


std::string x = boost::lexical_cast<std::string>
                    (second_clock::local_time().date().year());
Run Code Online (Sandbox Code Playgroud)

应该做.