Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6227389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:12:17+00:00 2026-05-24T09:12:17+00:00

I am looking for the boost::posix_time::time_input_facet that will let me parse milliseconds. It does

  • 0

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".

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:12:17+00:00Added an answer on May 24, 2026 at 9:12 am

    If you have a date/time string you can convert that into a ptime object like this:

    using boost::posix_time;
    ptime t = time_from_string(datetimeString);
    

    Having this you can easily get hold of the time_duration which holds the fractional seconds.

    time_duration td = t.time_of_day();
    long fs = td.fractional_seconds();
    

    You can also get the total milliseconds or microseconds like this:

    long ms = td.total_milliseconds();
    long us = td.total_microseconds();
    

    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_facet you can check the time_facet.hpp for appropriate format. Here is what you probably want to select from:

      static const char_type fractional_seconds_format[3];               // f                                                                                                                                 
      static const char_type fractional_seconds_or_none_format[3];       // F                                                                                                                                 
      static const char_type seconds_with_fractional_seconds_format[3];  // s
    

    UPDATE2

    In time_facet.hpp (Boost 1.45) I see the following when parsing:

    case 'f':
    {
        // check for decimal, check special_values if missing                                                                                                                                       
        if(*sitr == '.') {
            ++sitr;
            parse_frac_type(sitr, stream_end, frac);
            ...
    

    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?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I am looking for a library solution that does this: #include <boost/type_traits.hpp> template<bool>
I'm looking for a standard dual-map structure - is there one implemented in std/boost/another
I'm looking at boost::lambda as a way to to make a generic algorithm that
I'm looking for a way to boost my team's productivity, and one way to
I am looking for some STL (but not boost) container, which after the following
I'm looking for a C++ container that's a cross between boost::array, boost::scoped_array and std::vector.
I was looking at some code that uses Boost.Function and have a question about
I've been looking boost::tokenizer, and I've found that the documentation is very thin. Is
I'm looking for recommendations for open-source projects written in C++ that will help me
This one is for Boost experts. Are there any gotchas or details that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.