<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Finding the difference between dates</title>
	<link>http://www.jellyandcustard.com/2007/08/07/finding-the-difference-between-dates/</link>
	<description>Web Development Blog</description>
	<pubDate>Sat, 05 Jul 2008 00:20:39 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Justin</title>
		<link>http://www.jellyandcustard.com/2007/08/07/finding-the-difference-between-dates/#comment-21482</link>
		<pubDate>Tue, 04 Dec 2007 17:27:27 +0000</pubDate>
		<guid>http://www.jellyandcustard.com/2007/08/07/finding-the-difference-between-dates/#comment-21482</guid>
					<description>Thanks for this!

I modified your function to allow for an additional 'format' argument.  'format' allows you to customize the returned string.

function dateDiff($from,$to,$format='%%D%% d, %%H%% h, %%M%% m, %%S%% s'){
	$diff = $to - $from;
	$info = array('d'=&amp;#62;0,'h'=&amp;#62;0,'m'=&amp;#62;0,'s'=&amp;#62;0);
	if($diff&amp;#62;86400) {
		$info['d'] = ($diff - ($diff%86400))/86400;
		$diff = $diff%86400;
	}
	if($diff&amp;#62;3600) {
		$info['h'] = ($diff - ($diff%3600))/3600;
		$diff = $diff%3600;
	}
	if($diff&amp;#62;60) {
		$info['m'] = ($diff - ($diff%60))/60;
		$diff = $diff%60;
	}
	if($diff&amp;#62;0) {
		$info['s'] = $diff;
	}
	return str_replace(array('%%D%%','%%H%%','%%M%%','%%S%%'),array($info['d'],$info['h'],$info['m'],$info['s']),$format);
}

You can see it in action in the 'about us' section &lt;a href=&quot;http://www.barkhuff.com/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Thanks for this!</p>
<p>I modified your function to allow for an additional &#039;format&#039; argument.  &#039;format&#039; allows you to customize the returned string.</p>
<p>function dateDiff($from,$to,$format=&#039;%%D%% d, %%H%% h, %%M%% m, %%S%% s&#039;){<br />
	$diff = $to - $from;<br />
	$info = array(&#039;d'=&gt;0,&#039;h'=&gt;0,&#039;m'=&gt;0,&#039;s&#039;=&gt;0);<br />
	if($diff&gt;86400) {<br />
		$info[&#039;d'] = ($diff - ($diff%86400))/86400;<br />
		$diff = $diff%86400;<br />
	}<br />
	if($diff&gt;3600) {<br />
		$info[&#039;h'] = ($diff - ($diff%3600))/3600;<br />
		$diff = $diff%3600;<br />
	}<br />
	if($diff&gt;60) {<br />
		$info[&#039;m'] = ($diff - ($diff%60))/60;<br />
		$diff = $diff%60;<br />
	}<br />
	if($diff&gt;0) {<br />
		$info[&#039;s&#039;] = $diff;<br />
	}<br />
	return str_replace(array(&#039;%%D%%&#039;,'%%H%%&#039;,'%%M%%&#039;,'%%S%%&#039;),array($info[&#039;d'],$info[&#039;h'],$info[&#039;m'],$info[&#039;s&#039;]),$format);<br />
}</p>
<p>You can see it in action in the &#039;about us&#039; section <a href="http://www.barkhuff.com/" rel="nofollow">here</a>.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Mutiny Design</title>
		<link>http://www.jellyandcustard.com/2007/08/07/finding-the-difference-between-dates/#comment-15539</link>
		<pubDate>Fri, 17 Aug 2007 23:04:08 +0000</pubDate>
		<guid>http://www.jellyandcustard.com/2007/08/07/finding-the-difference-between-dates/#comment-15539</guid>
					<description>Thanks for this. Saved me an hour or two :)</description>
		<content:encoded><![CDATA[<p>Thanks for this. Saved me an hour or two <img src='http://www.jellyandcustard.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
