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 7682007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:28:10+00:00 2026-05-31T18:28:10+00:00

Are boost ptime instances always UTC? I can’t see any time zone info on

  • 0

Are boost ptime instances always UTC? I can’t see any time zone info on them.

  • 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-31T18:28:11+00:00Added an answer on May 31, 2026 at 6:28 pm

    The ptime has no associated timezone information. It does not know whether the content is in UTC or local time. In fact, you could do silly things like:

    #include <boost/date_time/posix_time/posix_time.hpp>
    #include <boost/date_time/c_local_time_adjustor.hpp>
    #include <iostream>
    
    int main()
    {
        using namespace boost::posix_time;
    
        ptime pt1 = microsec_clock::local_time();
        std::cout << "Local: " << pt1 << std::endl;
        std::cout << "UTC:   " << microsec_clock::universal_time() << std::endl;
    
        // !!!
        ptime pt2 = boost::date_time::c_local_adjustor<ptime>::utc_to_local(pt1);   
        std::cout << "Oops:  " << pt2 << std::endl;
    }
    

    and it will happily create a meaningless time for you.

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

Sidebar

Related Questions

how can I get current time with library boost. I can do this: ptime
I am using boost::posix_time::ptime to measure my simulation run-time and for something else. assuimg
I am trying to convert boost::posix_time::ptime from GMT to UTC. I went on Boost
I have a boost::posix_time::ptime that points to March 31st 2010 like this: ptime p(date(2010,
I'm trying to print a boost::posix_time::ptime in the format of YYYY-MM-DD hh:mm:ss.fff where the
Hi again with a boost question: I need to calculate the time spent in
I am using the boost library for getting the current system time and my
I would like to transfer a boost::posix_time::ptime over the network as a boost::int64_t .
I have a typedef boost::variant<int, float, double, long, bool, std::string, boost::posix_time::ptime> variant which I
I have following XML generated by serializing a boost::posix_time::ptime structure. I want to create

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.