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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:17:53+00:00 2026-05-24T10:17:53+00:00

I am writing a calendar-based web application and am working on some code that

  • 0

I am writing a calendar-based web application and am working on some code that will loop X amount of times and figure out the start/end dates & times of the future events. Each event has a start date/time and an end date/time The loop runs perfectly fine up until the year 2037, at which point the loop stop function properly. The conversion never takes place and reverts my dates back to 1969. Please see the code and output below. Can someone tell me why this is happening?

Live Example of Problem Behavior: http://codepad.org/h5ET3h2O

$date1 = strtotime('August 17 2011 8:00 AM');

for ($x=1; $x<=$repeatTimes; $x++){

    echo date('m/d/Y g:i A', $date1)."<br><br>".$date1 ." +". $repeatFreq." ".$repeatUnit. " = ";
    $date1 = strtotime(date('m/d/Y g:i A', $date1) . " +".$repeatFreq." ".$repeatUnit );
    echo $date1."<br /><br />";


}

Output

08/15/2011 8:00 AM
1313409600 +1 Year = 1345032000

08/15/2012 8:00 AM
1345032000 +1 Year = 1376568000

08/15/2013 8:00 AM
1376568000 +1 Year = 1408104000

//Some Left Out

08/15/2036 8:00 AM
2102414400 +1 Year = 2133950400

//Problem starts here

08/15/2037 8:00 AM
2133950400 +1 Year = 

12/31/1969 7:00 PM
+1 Year = 31536000

12/31/1970 7:00 PM
31536000 +1 Year = 63072000

12/31/1971 7:00 PM
63072000 +1 Year = 94694400

12/31/1972 7:00 PM
94694400 +1 Year = 126230400

12/31/1973 7:00 PM
126230400 +1 Year = 157766400

12/31/1974 7:00 PM
157766400 +1 Year = 189302400

//Some Left Out

UPDATE

I was able to utilize the DateTime Class to get the date working properly.

for ($x=1; $x<=$repeatTimes; $x++){
    $date1->modify(" +".$repeatFreq." ".$repeatUnit);
    $sDates[]=$date1->format('m/d/Y g:i A');
}
  • 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-24T10:17:55+00:00Added an answer on May 24, 2026 at 10:17 am

    http://en.wikipedia.org/wiki/Unix_time

    You’re hitting the max value of a 32-bit integer.

    Time is measured as the number of seconds since January 1, 1970 UTC. You see 1969 because in your timezone, that’s when this would occur. When the number of seconds overflows the 32-bit int, it loops back around.

    You can confirm the max integer value with this: echo PHP_INT_MAX;.

    If you want 64-bit integers, you need to use 64-bit hardware, and a 64-bit version of PHP (which usually these days, you have to compile yourself, as I don’t believe official binaries are available on PHP.net yet).

    There are also other options. See here: how to have 64 bit integer on PHP?

    Edit: Per Maerlyn’s suggestion, you should consider using the DateTime class built into recent versions of PHP. It should get you around this problem, as long as you use it consistently.

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

Sidebar

Related Questions

I'm writing a calendar control in .Net WinForms that will show a tooltip for
I'm writing a vertical scrollable calendar application(listview) that is always showing 1 month at
I'm writing an application that queries a user's Outlook calendar to see if they
Writing the code for the user authentication portion of a web site (including account
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
I am writing a month calendar-style control, and need to display a string that
I am writing an events calendar, and the data for the calendar I will
I'm writing a service that needs an up-to-date information on a user's calendar. However,
Writing some docs with code snippets which I want to be copyable to run
I´m writing an application for Android in which I have a character that 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.