<?xml version="1.0"?><rss version="2.0"><channel><title>Comments on PHP DateDiff Function - AddedBytes.com</title><link>http://www.addedbytes.com/article/php-datediff-function/</link><description>Latest comments on PHP DateDiff Function on AddedBytes.com</description><!-- ckey="76C662BB" --><item><title>Comment on PHP DateDiff Function</title><link>http://www.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.com/article/php-datediff-function/comments/</guid><description>Comment by Shariq ( &lt;a href=""&gt;&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;Great script Dave It saved my time but when you are going to provide update for existing bugs.</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.com/article/php-datediff-function/comments/</guid><description>Comment by Dave Child ( &lt;a href="http://www.addedbytes.com"&gt;http://www.addedbytes.com&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;Rosamunda: I'd suggest looking at the comments - several people have posted fixes and improvements to this script since it was published.&lt;br /&gt;
&lt;br /&gt;
As to whether it's working ... I've not updated it since my comment above, so I would run your own tests to ensure it's ok. I don't think it's far off, but it will still be a day out for leap years and daylight savings may cause problems too.&lt;br /&gt;
&lt;br /&gt;
As Super Mike pointed out above, there are almost certainly easier and more efficient ways to do this with existing PHP functionality.</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.com/article/php-datediff-function/comments/</guid><description>Comment by Rosamunda ( &lt;a href="http://rosamunda.blogspot.com"&gt;http://rosamunda.blogspot.com&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;I [desperately] need this script. Is it working? I mean, it works for me now, but I´ve read that you were going to update it because it was a bit buggy.&lt;br /&gt;
Is it safe now? &lt;br /&gt;
Thanks!!</description></item><item><title>Comment on PHP DateDiff Function</title><link>http://www.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.com/article/php-datediff-function/comments/</guid><description>Comment by Job ( &lt;a href=""&gt;&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.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.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.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.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.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.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.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.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.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.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.addedbytes.com/article/php-datediff-function/comments/</link><guid>http://www.addedbytes.com/article/php-datediff-function/comments/</guid><description>Comment by Tom ( &lt;a href=""&gt;&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></channel></rss>