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

  • Home
  • SEARCH
  • 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 393559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:16:10+00:00 2026-05-12T16:16:10+00:00

I discovered a strange result in Boost C++ date time library. There is inconsistency

  • 0

I discovered a strange result in Boost C++ date time library. There is inconsistency between microsec_clock and second_clock, and I don’t understand why is that. I am using Windows XP 32-bits

My snip of code:

using namespace boost::posix_time;
...
ptime now = second_clock::universal_time();
std::cout << "Current Time is: "<< to_iso_extended_string(now)<< std::endl;
ptime now_2 = microsec_clock::universal_time();
std::cout << "Current Time is: "<< to_iso_extended_string(now_2)<< std::endl;
...

The print-out I expected are current time without miliseconds and with milliseonds. However, what I have in my pc is:

2009-10-14T16:07:38  
1970-06-24T20:36:09.375890

I don’t understand why there is a weired date (year 1970???) in my microsec_clock time. Related documentation for Boost: link to boost date time

  • 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-12T16:16:11+00:00Added an answer on May 12, 2026 at 4:16 pm

    Not sure what could be wrong for you; the exact same code works for me.

    $ cat > test.cc
    #include <boost/date_time/gregorian/gregorian.hpp>
    #include <boost/date_time/posix_time/posix_time.hpp>
    using namespace boost::posix_time;
    int main() {
        ptime now = second_clock::universal_time();
        std::cout << "Current Time is: "<< to_iso_extended_string(now)<< std::endl;
        ptime now_2 = microsec_clock::universal_time();
        std::cout << "Current Time is: "<< to_iso_extended_string(now_2)<< std::endl;
        return 0;
    }
    ^D
    $ c++ -lboost_date_time test.cc
    $ ./a.out
    Current Time is: 2009-10-14T16:26:55
    Current Time is: 2009-10-14T16:26:55.586295
    

    Implementation-wise, second_clock uses time and microsec_clock uses gettimeofday or GetSystemTimeAsFileTime underneath, depending on the platform. Something appears wrong with your platform — what is your OS and version?


    What is your Boost version? If it is 1.38 or lower, upgrade to 1.39 or apply the fix to #2809 manually.

    --- boost/date_time/filetime_functions.hpp  (revision 53621)
    +++ boost/date_time/filetime_functions.hpp  (revision 53622)
    @@ -96,9 +96,7 @@
         {
             /* shift is difference between 1970-Jan-01 & 1601-Jan-01
             * in 100-nanosecond intervals */
    -        const uint64_t c1 = 27111902UL;
    -        const uint64_t c2 = 3577643008UL; // issues warning without 'UL'
    -        const uint64_t shift = (c1 << 32) + c2;
    +        const uint64_t shift = 116444736000000000ULL; // (27111902 << 32) + 3577643008
    
             union {
                 FileTimeT as_file_time;
    

    Windows FileTime has a different offset from UNIX time, and the code that was in Boost before would not generate the correct offset difference in certain optimizing compilers.

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

Sidebar

Related Questions

I just discovered that perl ignores space between the sigil and its variable name
I've today discovered some strange behaviour in IE8's implementation of the DOM select element's
Background While running benchmark tests this morning, my colleagues and I discovered some strange
We had discovered strange behaviour of popups in IE8. In IE7 and IE6 our
I've discovered a curious thing on my Mac. At some point I apparently created
(this is regarding the Ramaze.net framework) I ran into some really strange problems while
I've been using OpenID for my site for a while, and everything has been
I have been having the following problem, i think it's probably due to the
Something pretty weird is happening with my app: I have the following property in

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.