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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:49:56+00:00 2026-05-14T05:49:56+00:00

If I do date +%H-%M-%S on the commandline (Debian/Lenny), I get a user-friendly (not

  • 0

If I do date +%H-%M-%S on the commandline (Debian/Lenny), I get a user-friendly (not UTC, not DST-less, the time a normal person has on their wristwatch) time printed.

What’s the simplest way to obtain the same thing with boost::date_time ?

If I do this:

std::ostringstream msg;

boost::local_time::local_date_time t = 
  boost::local_time::local_sec_clock::local_time(
    boost::local_time::time_zone_ptr()
  );

boost::local_time::local_time_facet* lf(
  new boost::local_time::local_time_facet("%H-%M-%S")
);

msg.imbue(std::locale(msg.getloc(),lf));
msg << t;

Then msg.str() is an hour earlier than the time I want to see. I’m not sure whether this is because it’s showing UTC or local timezone time without a DST correction (I’m in the UK).

What’s the simplest way to modify the above to yield the DST corrected local timezone time ? I have an idea it involves boost::date_time:: c_local_adjustor but can’t figure it out from the examples.

  • 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-14T05:49:56+00:00Added an answer on May 14, 2026 at 5:49 am

    This does what I want:

      namespace pt = boost::posix_time;
      std::ostringstream msg;
      const pt::ptime now = pt::second_clock::local_time();
      pt::time_facet*const f = new pt::time_facet("%H-%M-%S");
      msg.imbue(std::locale(msg.getloc(),f));
      msg << now;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Date and time in MySQL can be stored as DATETIME, TIMESTAMP, and INTEGER (number
Given a date/time as an array of (year, month, day, hour, minute, second), how
I have a comma delimited file myfile.csv where the 5th column is a date/time
java.io.File doesn't provide a way to get a file's creation date. You can get
Date coming out of a database, need to format as mm/dd/yy For Each dr
Published Date returned from Twitter Search API Atom Feed as 2008-11-03T21:30:06Z which needs to
I coded something using Date statement in Access VBA. It was working fine until
The javascript Date("mm-dd-yyyy") constructor doesn't work for FF. It works fine for IE. IE
How is Oracle date implemented? Is it stored as milliseconds or something like that?
Given a date range, I need to know how many Mondays (or Tuesdays, Wednesdays,

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.