문제

I am new to the world of coding as well as php and am confused by why the strtotime and mktime functions return different results e.g.

$endyear = date('Y', strtotime('+5 years')); //returns 2011 - 2015
$endyear = date('Y', mktime(0,0,0,0,0,$year+5)); //returns 2011 - 2014

EDIT

The variable $year has the value of $2011.

도움이 되었습니까?

해결책

You're using zeroes for the month and day arguments, this essentially means

Day 0 = Last day of the previous month
Month 0 = Last month of the previous year

It's all there in the documentation - http://php.net/manual/en/function.mktime.php

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top