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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:00:48+00:00 2026-06-06T22:00:48+00:00

I am having an interesting problem with the mktime function. I looked at the

  • 0

I am having an interesting problem with the mktime function. I looked at the solutions offered on here prior and none seemed to be resolved or helped (strotime doesn’t change the results I see).

I have a monthly report that I am trying to make as error-proof as possible for my users, so I’m only requesting a month and a year. I will provide the best day for the report in the code.

My form has a drop-down selection for the months, and the values for the month are two-digit integers (01, 02, etc). The year is four-digit, filled out manually by the user.

Every works great up until the year 2038… I know, I know, it’s a long way off, but the project is supposed to have a 20-year scope and so in the last two years, I’m running into issues.

here’s how I’m receiving the information from the form:

$month = filter_var($_POST["month"], FILTER_SANITIZE_NUMBER_INT);
$year = filter_var($_POST["year"], FILTER_SANITIZE_NUMBER_INT);

Then, I use mktime to combine the month and year with my day (27th):
$timeStamp = mktime(0,0,0,$month,27,$year);

Then I assign it to a variable in a date form that MySQL likes:
$reportdate = date(‘Y-m-j’,$timeStamp);

I’ve echoed out the results of $month and $year and they are coming across correctly, but when I echo out $reportdate, it always says 12/31/1969.

03
2038
1969-12-31

It doesn’t matter what month I choose. December 2037 reports perfectly, anything beyond that fails.

Is this something that is fixable or am I just going to have to say that’s the way the cookie crumbles…?

  • 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-06T22:00:49+00:00Added an answer on June 6, 2026 at 10:00 pm

    This is because your timestamp is overflowing, and is caused by the year 2038 problem.

    Basically, integers are represented as signed 32-bits numbers, which can hold a maximum value of 2147483648. So, in a UNIX timestamp, that is a certain amount in seconds, which is about 68 years.

    In fact, Google tells me:

    (2^31) * seconds = 68.0511039 years
    

    So, UNIX timestamp is time since the UNIX epoch, Jan 1st 1970 00:00:00 UTC, meaning the largest date that can be represented in a 32-bit UNIX timestamp would have a year of:

    1970 + ~68 = ~2038.
    

    If you need to support these dates, use the DateTime class, as it does not have such a restriction, like so:

    $date = new DateTime( "now", new DateTimeZone( 'America/New_York'));
    $date->setDate( $year, $month, 27);
    // $date->setTime( 0, 0, 0);
    echo $date->format('Y-m-j');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's an interesting problem: I have some jQuery that looks like this: $(document).ready(function() {
C#.NET 4.0 I'm having an interesting problem here with reading a custom file archive
I am having an interesting problem with using pinvoke in C# to call _snwprintf.
So I have an interesting problem I am having issues with the jquery .load()
I am having a problem with calling a ext function in odata4j in android
PHP mySQL Hi, i am having an interesting problem. I have a form in
I am having a very interesting problem. The script I wrote below works, but
I'm having an interesting but difficult problem with my JavaScript code. Basically, I'm trying
I'm having an interesting problem...that I can't seem to find the solution for. I'm
Good day, I am having an interesting problem that I cannot understand. I have

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.