如何使用Poco获取当前日期? 仅日期无时间戳记

问题描述

有没有办法让我们仅从Poco获得日期?一种方法获取Poco DateTime戳并截断Date,但是有什么方法可以直接给出当前Date? 例如,例如,我正在使用这种方式获取日期

void getTimestamp(std::string &out_iTimestamp)
{
   //Get the CurrentTimestamp
   Poco::Timestamp t_oCurTimestamp;
   Poco::DateTimeFormatter t_oFormatter;
   string t_strDateTime;
   t_oFormatter.append(t_strDateTime,t_oCurTimestamp,Poco::DateTimeFormat::ISO8601_FORMAT);
   out_iTimestamp = t_strDateTime;

} 现在我要删掉日期

std::string t_strDateTime;
std::string t_strDate;
getTimestamp(t_strDateTime);
//extract the only Date from DateTimeStamp
std::size_t found = t_strDateTime.find('T');
if (found != std::string::npos){
    t_strDate = t_strDateTime.substr(0,found);
}

有人知道简单的方法吗?

解决方法

已经回答here,请以自己的格式使用Poco :: DateTimeFormatter:

Poco::DateTimeFormatter::format(date,"%d/%m/%Y");