you can try this code:
void FormatDateTime(
std::string const& format,
boost::posix_time::ptime const& date_time,
std::string& result)
{
boost::posix_time::time_facet * facet =
new boost::posix_time::time_facet(format.c_str());
std::ostringstream stream;
stream.imbue(std::locale(stream.getloc(), facet));
stream << date_time;
result = stream.str();
}
Set the format "%d-%m-%Y %H:%M:%S"or any other face you want.
For local time, use boost::posix_time::second_clock::local_time()( date_time) as the second argument .
source
share