note 54250 modified in function.strtotime by danbrown

From: Date: Sun, 20 Jul 2008 04:09:36 +0000
Subject: note 54250 modified in function.strtotime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142113@lists.php.net to get a copy of this message
This is an easy way to calculate the number of months between 2 dates (including the months in which the dates are themselves). <?php $startDate = mktime(0,0,0, 6, 15, 2005); $stopDate = mktime(0,0,0, 10, 8, 2006); $nrmonths = ((idate('Y', $stopDate) * 12) + idate('m', $stopDate)) - ((idate('Y', $startDate) * 12) + idate('m', $startDate)); ?> Results in $nrmonths = 16. --was-- This is an easy way to calculate the number of months between 2 dates (including the months in which the dates are themselves). <? $startDate = mktime(0,0,0, 6, 15, 2005); $stopDate = mktime(0,0,0, 10, 8, 2006); $nrmonths = ((idate('Y', $stopDate) * 12) + idate('m', $stopDate)) - ((idate('Y', $startDate) * 12) + idate('m', $startDate)); ?> Results in $nrmonths = 16. http://php.net/manual/en/function.strtotime.php

« previous php.notes (#142113) next »