<?xml version="1.0"?><rss version="2.0"><channel><title>Comments on PHP DateDiff Function - ILoveJackDaniels.com</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/</link><description>Latest comments on PHP DateDiff Function on ILoveJackDaniels.com</description><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by Job ( &lt;a href="http://"&gt;http://&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;So long already yet no latest update?</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by Super Mike ( &lt;a href=""&gt;&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;Meant the previous post to read &quot;4 months prior to current date&quot;, not &quot;past current date&quot;. But you get the point.</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by Super Mike ( &lt;a href=""&gt;&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;Check this bad boy out:&lt;br /&gt;&lt;br /&gt;	function DateComp($sDateA, $sDateB_ForInterval, $sInterval, $bUseTimeStamps = FALSE) {&lt;br /&gt;		$sFormat = ($bUseTimeStamps) ? 'Y-m-d H:i:s' : 'Y-m-d';&lt;br /&gt;		$sDateA = (($sDateA == '') || (empty($sDateA))) ? gmdate($sFormat) : $sDateA;&lt;br /&gt;		$dDateA = strtotime(date($sFormat, strtotime($sDateA)));&lt;br /&gt;		$sDateB = $sDateB_ForInterval;&lt;br /&gt;		$sDateB = (($sDateB == '') || (empty($sDateB))) ? gmdate($sFormat) : $sDateB;&lt;br /&gt;		$dDateB = strtotime(date($sFormat, strtotime($sDateB)));&lt;br /&gt;		$dTempDate = strtotime($sInterval, $dDateB);&lt;br /&gt;		return ($dTempDate &gt; $dDateA);&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	/* &lt;br /&gt;	&lt;br /&gt;	// USAGE OF DateComp:&lt;br /&gt;	$sDBDate = '2007-10-15 23:16:28';&lt;br /&gt;	$sCurrDate = gmdate('Y-m-d');&lt;br /&gt;	if (DateComp($sDBDate, $sCurrDate, '- 4 months')) {&lt;br /&gt;		echo &quot;DB date value is older than 4 months past current date.&quot;;&lt;br /&gt;	} else {&lt;br /&gt;		echo &quot;DB date value is newer than 4 months past current date.&quot;;&lt;br /&gt;	}&lt;br /&gt;	*/</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by Super Mike ( &lt;a href=""&gt;&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;You know, I don't see why this has to be so complicated. I mean, lest we forget that the strtotime function has the ability to add or subtract any interval of time you want with its first optional parameter. So you could compare differences between dates quite easily with it.&lt;br /&gt;&lt;br /&gt;http://us2.php.net/manual/en/function.strtotime.php&lt;br /&gt;&lt;br /&gt;It doesn't involve parsing the dates, which consumes precious processor time, and the function runs at C-level for things you would be running at PHP-level with a function like the one used here at ilovejackdaniels.com.</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by China Landscape ( &lt;a href="http://www.photos-china.com"&gt;http://www.photos-china.com&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;Huu, you don't find somethig more complicated ???</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by Wreckman ( &lt;a href=""&gt;&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;I found the mistake in the number of weekdays case :&lt;br /&gt;&lt;br /&gt;It's written :&lt;br /&gt;$weeks_difference = floor($days_difference / 7);&lt;br /&gt;&lt;br /&gt;Replace with :&lt;br /&gt;If(abs($days_difference) &gt;= 7) {&lt;br /&gt;   $weeks_difference = floor($days_difference / 7);&lt;br /&gt;}&lt;br /&gt;Else {&lt;br /&gt;   $weeks_difference = 0;&lt;br /&gt;}</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by Tom ( &lt;a href="http://"&gt;http://&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;would someone be able to apply all of the needed updates and re-release it or just post it in a comment? it would be very helpful</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by adib ( &lt;a href="http://www.tdoq.com"&gt;http://www.tdoq.com&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;looking for this script for some time. I found another script here.&lt;br /&gt;&lt;br /&gt;http://tinyurl.com/392hn4&lt;br /&gt;&lt;br /&gt;but this script just calculate in days.</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by eval ( &lt;a href="http://"&gt;http://&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;This is what exactly i  needed!! Thank you very much for sharing it</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</link><guid>http://www.ilovejackdaniels.com/article/php-datediff-function/comments/</guid><description>Comment by rjekolod ( &lt;a href="http://holdem-001.retproject.info/

"&gt;http://holdem-001.retproject.info/

&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;Hi &lt;br /&gt; &lt;br /&gt;Looks good! Very useful, good stuff. Good resources here. Thanks much! &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;G'night</description></item></channel></rss>