PeanutsMonkey
PeanutsMonkey

Reputation: 7105

PHP strtotime and mktime return different results

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.

Upvotes: 1

Views: 2133

Answers (1)

Phil
Phil

Reputation: 165069

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

Upvotes: 3

Related Questions