I need to get a nicely formatted timestamp (slightly modified ISO 8601) with millisecond precision.
And example date would look like this: 2011-09-28 13:11:15.237-08:00
The formatting should be able to be overwridden as well.
I've been playing around with boost::posix_time::microsec_clock::local_time()
and boost::posix_time::time_facet
which works just fine except when it comes to timestamps.
Since posix time doesn't contain time zone information this is just not possible (I'm guessing)
So, is there anything else I could use that has millisecond precision that contains timezone information or can I make the time_facet
work with timezones?
Maybe I should always use UTC?
Thanks
Have a look at the boost::local_time::local_date_time class. You can specify a time zone and use the local microsecond clock to initialize it like
You should then be able to use the facets to format to a string.
Edit: Full example: