The Problematic Code
I am trying to build a time using some string values extracted from a file. This is basically the code that runs.
$hour = "18";
$minutes = "0";
$month = "28";
$day = "4";
$year = "2016";
echo("<div>"."Current PHP version: " . phpversion()."</div>");
echo("<div>hour :: ".(int)$hour."</div>");
echo("<div>minutes :: ".(int)$minutes."</div>");
echo("<div>month :: ".(int)$month."</div>");
echo("<div>day :: ".(int)$day."</div>");
echo("<div>year :: ".(int)$year."</div>");
$built_time = mktime((int)$hour,(int)$minutes,0,(int)$month,(int)$day,(int)$year);
echo("<div> Built Time [Y-m-d H:i:s]: ".date( 'Y-m-d H:i:s',$built_time)."</div>");
The Wrong Results
The output is receive for this is:
Several more attempts yielded the following results
As you can see sometimes it does provide the correct result! Why does this happen. It cannot be a timezone issue since its giving dates which are years into the future.
As per mktime() documentation the parameter sequence is also correct. Wonder why this call is failing.