I've got this code:
<?php
$data = array(array("1","name1","2050-10-10"),array("2","name1","2051-10-10"));
$date = date("Y-m-d");
$x = 2;
foreach($data as $day)
{
$interval[] = abs(strtotime($date) - strtotime($day[$x]));
$interval[] = $day[$x];
}
var_dump($interval);
?>
I tried it on my own server :
It returns :
array(1) {
[0]=> array(4) {
[0]=> int(1418338800)
[1]=> string(10) "2050-10-10"
[2]=> int(1418338800)
[3]=> string(10) "2051-10-10"
}
}
but http://writecodeonline.com/php/ returns :
array(4) {
[0]=>
int(1130716800)
[1]=>
string(10) "2050-10-10"
[2]=>
int(1162252800)
[3]=>
string(10) "2051-10-10"
}
I don't understand why the value 1418338800 stays the same and I wonder how I could solve this problem!
Thank you a lot in advance
Following the @Jonathan Kuhn advice:
<?php
echo strtotime("2051-10-10");
echo strtotime("2050-10-10");
echo strtotime("2040-10-10");
echo strtotime("2039-10-10");
echo strtotime("2038-10-10");
echo strtotime("2037-10-10");
echo strtotime("2036-10-10");
?>
It returns:
empty line
empty line
empty line
empty line
empty line
2138738400
2107202400
The problem came from the 32 bit system.