Hi guys, I didn't find this in documentation: how to get local time (better formatted) with boost?
Use the Date Time Input/Output APIs:
http://www.boost.org/doc/libs/1_42_0/doc/html/date_time/date_time_io.html#date_time.io_objects
I don't know if this will be of any help, but boost docs have some examples of formatting dates.
Plus, I think that this article describes some basics, which are worth looking at.
Use posix_time to construct a time object from the system clock.
For example, this would output the current system time as an ISO-format string:
namespace pt = boost::posix_time;
pt::to_iso_string(pt::second_clock::local_time());
For formatting alternatives, see the “Conversion to String” section of the above-linked reference and the Date Time Input/Output reference. Alternatively, you can build your own output string using the accessor functions. For example, to get a US-style date:
namespace pt = boost::posix_time;
pt::ptime now = pt::second_clock::local_time();
std::stringstream ss;
ss << static_cast<int>(now.date().month()) << "/" << now.date().day()
<< "/" << now.date().year();
std::cout << ss.str() << std::endl;
Note the month is cast to int
so it will display as digits. The default output facet will display it as the three-letter month abbreviation (“Mar” for March).