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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:02:10+00:00 2026-06-09T21:02:10+00:00

I have to find the date 4,000,000 seconds from now. I can get the

  • 0

I have to find the date 4,000,000 seconds from now. I can get the correct answer if I add 4,000,000 to secondsSince1970, but I was wondering why it doesn’t work if I add 4,000,000 to now.tm_sec?

int main(int argc, const char * argv[])
{
    long secondsSince1970 = time(NULL) + 4000000;

    struct tm now;

    localtime_r(&secondsSince1970, &now);

    printf("The date from 4,000,000 seconds from now is %i-%i-%i\n", now.tm_mon + 1, now.tm_wday, now.tm_year + 1900);
}

Output:
The date is 10-1-2012


int main(int argc, const char * argv[])
{
    long secondsSince1970 = time(NULL);

    struct tm now;

    localtime_r(&secondsSince1970, &now);
    now.tm_sec += 4000000;

    printf("The date from 4,000,000 seconds from now is %i-%i-%i\n", now.tm_mon + 1, now.tm_wday, now.tm_year + 1900);
}

Output: The date is 8-4-2012

  • 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-06-09T21:02:12+00:00Added an answer on June 9, 2026 at 9:02 pm

    Your struct tm is just a bunch of variables that get filled in by localtime_r. After the call to localtime_r, assigning to one of these variables will not magically make the other ones change their values.

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

Sidebar

Related Questions

I have two date entities, start_date and end_date and now I want to find
I have an array of Ruby Date objects. How can I find the newest
I have unstructured string. From this I need to find the date. Example: [expected
I've skimmed thru Date and Silberschatz but can't seem to find answers to these
I have two Java instances of java.util.Date and I have to find out if
Is there anyway to find the date difference in php? I have the input
i have a date in the future and i want to find out how
I have tried a long time to find help regarding a random date in
I have start date and end date. I need to find out the day
I have a SQL Server database which contains date like 2012-01-10 00:00:00.000 When I

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.