I am looking for the boost::posix_time::time_input_facet that will let me parse milliseconds. It does not seem to be the same as the one for formatting microseconds which is "%f"
So if I have 2011-12-11 08:29:53.123000, I would like to have the right formatting to parse it, something like that "%Y-%m-%d %H:%M:%S".
If you have a date/time string you can convert that into a ptime object like this:
Having this you can easily get hold of the time_duration which holds the fractional seconds.
You can also get the total milliseconds or microseconds like this:
More information about what can be done in the documentation.
UPDATE
If the input format might be a different one, so you want to use the
time_input_facetyou can check thetime_facet.hppfor appropriate format. Here is what you probably want to select from:UPDATE2
In
time_facet.hpp(Boost 1.45) I see the following when parsing:I don’t see why this would require anything but a dot between the seconds and the fractional seconds. Maybe you use another version of Boost?