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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:07:33+00:00 2026-05-25T20:07:33+00:00

I am using the mktime(struct tm*) function in Suse 10. Now, I am noticing

  • 0

I am using the mktime(struct tm*) function in Suse 10.

Now, I am noticing some strange behaviour when daylight saving time is enabled. Let’s say I have enabled daylight saving time to begin on Sep 15 at 18:10 and the daylight correction is for 30 minutes. Now, when I call mktime with tm structure having the date as Sep 15 18:10 and tm_isdst is set to 0, then I get back the same values in the tm structure only with the tm_isdst set to 1.

But, if the pass the date as Sep 15 18:10 with tm_isdst set to 1, then I find the time changed to 17:40. This correction in the tm structure is noticed for time passed between Sep 15 18:10 to Sep 15 18:40, but after that no correction in time happens and teh dst flag remains enabled. Even if I pass the date as Sep 16 18:10, no time correction happens only dst flag remains enabled.

I am totally confused. Is this the correct behavior of mktime?

  • 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-25T20:07:33+00:00Added an answer on May 25, 2026 at 8:07 pm

    If the local time changes by 30 minutes for DST, then once per year there’s 30 minutes of local time that happens twice (once with DST, and once without) and another 30 minutes that never happens (it gets skipped when the time changes).

    So local times within 30 minutes of when the clock gets set back are ambiguous, unless whether DST is in effect is specified; there are two actual instants in time that they could correspond to.

    Local times within 30 minutes of when the clock gets set ahead are invalid; there are no actual instants in time they could correspond to (though the conversion might still be done by supposing that DST is in effect, or not in effect).

    So for some local times (ignoring the DST state) there could be more than one corresponding UTC time, but for any given UTC time there is only one possible local time (if DST adjustments are accounted for properly).

    When you call mktime, it’s converting the local time you give it to a time_t as though DST is either in effect or not, depending on the value of tm_isdst. The corrected values you get back are based on the reverse of this conversion, and the system will determine whether you get a DST time or a non-DST time, depending on its idea of whether DST is in effect at the time from the conversion. The time you gave it and the time you got back actually represent the same moment in time, but with different offsets from UTC due to the different DST states.

    So yes, this is the correct behaviour of mktime. It is supposed to normalize the values in the structure, according to its idea of how to properly represent the time you gave it.

    This also illustrates why one should be careful about using local time keep track of actual events — if the DST state or offset from UTC is not saved along with the time, some local time values can be ambiguous.

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

Sidebar

Related Questions

ok i have a birthday form that will save as time using mktime, so
I am using following to convert time to integer mktime(hour,minute,second,month,day,year) How would I reverse
I'm using this to convert date time strings to a unix timestamp: str(int(time.mktime(time.strptime(date,%d %b
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Today is 24 gen 2012 for Europe. I'm using mktime to get a DateTime
I am using a unix time stamp as the base of my starting date
I was trying to make my own php mktime(); using my default timezone *(America/Sao_Paulo)*.
$datef = (date(Y-m-d,mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']))); Out of interest, i'm using this
I have been using this function for a while without a problem, although I
I'm using < time.h > to convert between strings and dates in c++. int

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.