Limit for strtotime function in php [duplicate]

4

I'm using the strtotime function as shown below, with cakephp. by passing the sum of 50 years it is returning null, the maximum that I can return is summing 20 years.

Would anyone know if this is limiting / configuring cakephp or php itself?

date('d/m/Y', strtotime('+50years'));
    
asked by anonymous 25.01.2016 / 15:01

1 answer

6

According to the documentation, the date () function limit is 19/01/2038 , as PHP uses a 32-bit integer to render that date.

To work around the problem use the DateTime class, in the example below a 50-year period has been added (% with%).

$data = new DateTime();
$data->add(new DateInterval('P50Y'));
echo $data->format('d/m/Y'); //25/01/2066
    
25.01.2016 / 15:05