Accessing dates in PHP beyond 2038
You can alternatively use the DateTime
class, which internally represents the time components independently. Thus it is not susceptible to the 2038 limitation (unless you use ::getTimestamp).
touch function in PHP 7 64-bit does not handle dates beyond 2038
I reported it as a bug in PHP and it was fixed the next day!
Bug #78241 is fixed starting with PHP 7.3.8 & 7.2.21.
Why can't I add more than 7400 days to date in php?
Likely it is due to the Year 2038 problem combined with a 32bit version of PHP.
You can check your php version by checking the value of the PHP_INT_SIZE
constant (which will be 4 for x32 and 8 for x64).
Any dates after january 19'th 2038 overflows the 32-bit signed integer used for the Unix timestamp.
5000 days from today is March 27, 2032
7500 days from today is January 30, 2039
Using a 64bit version of PHP you should be good until year 292277026596.
Why do timestamps have a limit to 2038?
The limit is imposed by the 4 byte signed integers that most C libraries use for representing that count. Quick math (assumes 365 day years, not exactly correct):
2147483648 seconds ~ 68.1 years
This also implies a lower limit of ~1900. Some libraries have started to introduce 64 bit epoch counts, but they are few and far between for the moment.
Related Topics
How to Extract Text from Word File .Doc,Docx,.Xlsx,.Pptx PHP
Accurate Way to Measure Execution Times of PHP Scripts
: Operator (The 'Elvis Operator') in PHP
MySQL Datetime Fields and Daylight Savings Time - How to Reference the "Extra" Hour
Lamp: How to Create .Zip of Large Files For the User on the Fly, Without Disk/Cpu Thrashing
Get Data from Json File With PHP
How to Find Out Where a Function Is Defined
"Unknown Modifier 'G' In..." When Using Preg_Match in PHP
Difference Between JavaScript and PHP
Does Sleep Time Count For Execution Time Limit
How to Remove All Specific Characters At the End of a String in PHP
Unformat Money When Parsing in PHP
Reading and Writing Configuration Files
Implementing Condition in Xpath
Including a Remote File in PHP