Search code examples
phpdatestrtotime

Dates after 01-01-2039 converted in PHP is shown as 01-01-1970


I have converted a date 01-01-2039 using php date() function:

echo date("d-m-Y",strtotime('01-01-2039'));

Output is shown as: 01-01-1970

Any solution for this?


Solution

  • This Answer from comment conversation

    The problem is caused by the Unix Timestamp Epoch problem.

    The solution to this for native PHP is to use the 64bit PHP version that correctly handles this particular integer overflow.

    echo (PHP_INT_SIZE===8)?"64 bit ":"32 bit ";
    

    This above code shows the PHP version.

    If 32bit PHP is present then that needs to be replaced by the 64bit PHP