<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PHP: Loop through dates (from date to date) with strtotime() function</title>
	<atom:link href="http://www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/</link>
	<description>If !1 0 &#124; Linux and Development Guides</description>
	<lastBuildDate>Fri, 10 Feb 2012 20:00:37 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<div style="position:absolute;top:-9999px;left:-9999px;"><a href="http://www.if-not-true-then-false.com/hp/fitting.php" rel="nofollow">forum</a></div>	<item>
		<title>By: Ezeelive</title>
		<link>http://www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/comment-page-1/#comment-23051</link>
		<dc:creator>Ezeelive</dc:creator>
		<pubDate>Sun, 29 Jan 2012 17:13:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.if-not-true-then-false.com/?p=299#comment-23051</guid>
		<description>Nice post.Thanks for sharing</description>
		<content:encoded><![CDATA[<p>Nice post.Thanks for sharing</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JR</title>
		<link>http://www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/comment-page-1/#comment-20207</link>
		<dc:creator>JR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 09:33:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.if-not-true-then-false.com/?p=299#comment-20207</guid>
		<description>Hi yo,

Yes you can do it many ways, but my example try to show method which works nicely even if you change +1 day to +4 days, 1 week, 1 month, 2 years, etc.

Most powerful way to do this is minimize strtotime and date functions usage. So your example is good, but following is even more efficient:
&lt;pre lang=&quot;php&quot;&gt;
$start = strtotime(&#039;2011-11-01&#039;);
$end = strtotime(&#039;2011-11-28&#039;);
for ( $i = $start; $i &lt;= $end; $i += 86400 ){

	// do stuff here
	echo date(&#039;Y-m-d&#039;);

}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hi yo,</p>
<p>Yes you can do it many ways, but my example try to show method which works nicely even if you change +1 day to +4 days, 1 week, 1 month, 2 years, etc.</p>
<p>Most powerful way to do this is minimize strtotime and date functions usage. So your example is good, but following is even more efficient:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="color:#D8D8D8;"><span style="color: #729fcf;">$start</span> <span style=" color: #FFF;">=</span> <span style="color: #d3d7cf">strtotime</span><span style=" color: #FFF;">&#40;</span><span style="color: #FFC600;">'2011-11-01'</span><span style=" color: #FFF;">&#41;</span><span style=" color: #FFF;">;</span>
<span style="color: #729fcf;">$end</span> <span style=" color: #FFF;">=</span> <span style="color: #d3d7cf">strtotime</span><span style=" color: #FFF;">&#40;</span><span style="color: #FFC600;">'2011-11-28'</span><span style=" color: #FFF;">&#41;</span><span style=" color: #FFF;">;</span>
<span style="color: #FFF; font-weight:bold;">for</span> <span style=" color: #FFF;">&#40;</span> <span style="color: #729fcf;">$i</span> <span style=" color: #FFF;">=</span> <span style="color: #729fcf;">$start</span><span style=" color: #FFF;">;</span> <span style="color: #729fcf;">$i</span> <span style=" color: #FFF;">&lt;=</span> <span style="color: #729fcf;">$end</span><span style=" color: #FFF;">;</span> <span style="color: #729fcf;">$i</span> <span style=" color: #FFF;">+=</span> <span style="color: #7FB347;">86400</span> <span style=" color: #FFF;">&#41;</span><span style=" color: #FFF;">&#123;</span>
&nbsp;
	<span style=" color: #C7DD0C">// do stuff here</span>
	<span style="color: #FFF; font-weight:bold;">echo</span> <span style="color: #d3d7cf">date</span><span style=" color: #FFF;">&#40;</span><span style="color: #FFC600;">'Y-m-d'</span><span style=" color: #FFF;">&#41;</span><span style=" color: #FFF;">;</span>
&nbsp;
<span style=" color: #FFF;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: yo</title>
		<link>http://www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/comment-page-1/#comment-20204</link>
		<dc:creator>yo</dc:creator>
		<pubDate>Tue, 29 Nov 2011 07:46:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.if-not-true-then-false.com/?p=299#comment-20204</guid>
		<description>&lt;pre&gt;
for ($i = strtotime(&#039;2011-11-01&#039;);$i &lt;= strtotime(&#039;2011-11-28&#039;);$i += 86400){

	// do stuff here
	echo date(&#039;Y-m-d&#039;);

}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre>
for ($i = strtotime('2011-11-01');$i &lt;= strtotime(&#039;2011-11-28&#039;);$i += 86400){

	// do stuff here
	echo date(&#039;Y-m-d&#039;);

}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Health Product</title>
		<link>http://www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/comment-page-1/#comment-18422</link>
		<dc:creator>Health Product</dc:creator>
		<pubDate>Mon, 08 Aug 2011 06:15:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.if-not-true-then-false.com/?p=299#comment-18422</guid>
		<description>fantastic code.. working perfectly. thanks to JR to post such useful php code :)</description>
		<content:encoded><![CDATA[<p>fantastic code.. working perfectly. thanks to JR to post such useful php code :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cristian</title>
		<link>http://www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/comment-page-1/#comment-17247</link>
		<dc:creator>cristian</dc:creator>
		<pubDate>Thu, 18 Nov 2010 21:55:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.if-not-true-then-false.com/?p=299#comment-17247</guid>
		<description>This is cool, i didn&#039;t know you could do that! Very useful!</description>
		<content:encoded><![CDATA[<p>This is cool, i didn&#8217;t know you could do that! Very useful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Janene Failde</title>
		<link>http://www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/comment-page-1/#comment-464</link>
		<dc:creator>Janene Failde</dc:creator>
		<pubDate>Wed, 17 Mar 2010 19:34:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.if-not-true-then-false.com/?p=299#comment-464</guid>
		<description>Nice post. Been learning basic PHP. Your guides really help</description>
		<content:encoded><![CDATA[<p>Nice post. Been learning basic PHP. Your guides really help</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- This Quick Cache file was built for (  www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/feed/ ) in 0.12199 seconds, on Feb 11th, 2012 at 7:52 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 11th, 2012 at 8:52 am UTC -->
