<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB"><title>Comments on PHP DateDiff Function - AddedBytes.com</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/" /><link rel="self" type="application/xml" href="http://www.addedbytes.com/article/php-datediff-function/comments/atom/" /><subtitle>Latest comments on PHP DateDiff Function on AddedBytes.com</subtitle><author><name>Dave Child</name></author><updated>2004-04-20T13:53:00Z</updated><id>tag:addedbytes.com,2004:51</id><!-- ckey="76C662BB" --><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">Comment by khaild ( &lt;a href=""&gt;&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;wow so many comments, here goes another comment...&lt;br /&gt;
&lt;br /&gt;
thanks for bearing so many comments !!!! :D</summary><id>tag:addedbytes.com,2008:105790</id><published>2008-10-22T11:10:37+01:00</published><updated>2008-10-22T11:10:37Z</updated></entry><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">Comment by Don ( &lt;a href=""&gt;&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;This worked great and saved me a lot of time. The only change I made was to decrement the $days_remainder value when $first_day was a '0' (Sunday) and $days_remainder &gt; 0 for the weekday calculation. Without this I was getting an extra day when $datefrom started on a Sunday. I added the following:&lt;br /&gt;
&lt;br /&gt;
if ($first_day == 0 &amp;&amp; $days_remainder &gt; 0) {// must account for Sunday if datefrom is a Sunday&lt;br /&gt;
            $days_remainder--;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
just before the final value of $datediff is calculated.</summary><id>tag:addedbytes.com,2008:104511</id><published>2008-09-12T15:02:48+01:00</published><updated>2008-09-12T15:02:48Z</updated></entry><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">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.</summary><id>tag:addedbytes.com,2008:103830</id><published>2008-08-21T13:17:57+01:00</published><updated>2008-08-21T13:17:57Z</updated></entry><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">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.</summary><id>tag:addedbytes.com,2008:97534</id><published>2008-07-05T21:09:56+01:00</published><updated>2008-07-05T21:09:56Z</updated></entry><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">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!!</summary><id>tag:addedbytes.com,2008:97529</id><published>2008-07-05T18:57:10+01:00</published><updated>2008-07-05T18:57:10Z</updated></entry><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">Comment by Job ( &lt;a href=""&gt;&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;So long already yet no latest update?</summary><id>tag:addedbytes.com,2008:94426</id><published>2008-05-01T07:27:54+01:00</published><updated>2008-05-01T07:27:54Z</updated></entry><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">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.</summary><id>tag:addedbytes.com,2008:76795</id><published>2008-02-15T01:49:52+00:00</published><updated>2008-02-15T01:49:52Z</updated></entry><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">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;	*/</summary><id>tag:addedbytes.com,2008:76794</id><published>2008-02-15T01:48:44+00:00</published><updated>2008-02-15T01:48:44Z</updated></entry><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">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.</summary><id>tag:addedbytes.com,2008:76790</id><published>2008-02-15T01:19:31+00:00</published><updated>2008-02-15T01:19:31Z</updated></entry><entry><title>Comment on PHP DateDiff Function</title><link rel="alternate" type="text/html" href="http://www.addedbytes.com/article/php-datediff-function/comments/" /><summary type="text">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 ???</summary><id>tag:addedbytes.com,2007:63128</id><published>2007-11-26T04:35:27+00:00</published><updated>2007-11-26T04:35:27Z</updated></entry></feed>