PHP - mktime() function returning wrong time -


the problematic code

i trying build time using string values extracted file. code 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 receive is:

output given code snippet

several more attempts yielded following results

other attempts

as can see provide correct result! why happen. cannot timezone issue since giving dates years future.

as per mktime() documentation parameter sequence correct. wonder why call failing.

the result correct according inputs.

mktime accetps month value between 1-12. in each of attempts except last 1 month values 28,28,21,21.

so when value of month more 12, references appropriate month in following year(s). in first 2 case 04 , and in 3rd , 4th 09.

when pass value of month greater 12 calculates n months after current month. in first 2 cases it's april 2018(04) , and in 3rd , 4th it's september(09) 2017.

so outputs correct according inputs.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -