<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
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/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Yostivanich &#187; complex</title> <atom:link href="http://www.yostivanich.com/tag/complex/feed/" rel="self" type="application/rss+xml" /><link>http://www.yostivanich.com</link> <description>Surfing the web and hopefully learning something new every day</description> <lastBuildDate>Sat, 04 Sep 2010 04:48:52 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <atom:link rel='hub' href='http://www.yostivanich.com/?pushpress=hub'/> <item><title>The Complex Made Simple</title><link>http://www.yostivanich.com/2009/01/27/the-complex-made-simple/</link> <comments>http://www.yostivanich.com/2009/01/27/the-complex-made-simple/#comments</comments> <pubDate>Tue, 27 Jan 2009 06:37:13 +0000</pubDate> <dc:creator>Justin Yost</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[Software Code]]></category> <category><![CDATA[complex]]></category> <category><![CDATA[date]]></category> <category><![CDATA[function]]></category> <category><![CDATA[php]]></category> <category><![CDATA[php.net]]></category> <category><![CDATA[simple]]></category> <category><![CDATA[strtotime]]></category> <category><![CDATA[stupid]]></category> <category><![CDATA[unix]]></category><guid
isPermaLink="false">http://www.yostivanich.com/?p=471</guid> <description><![CDATA[For work, I had a piece of code that needed to calculate if a certain date fell in between two other days. So I started out writing out this big long function to calculate if a date fell first within the same year as either of the two dates, and if so within the two [...]]]></description> <content:encoded><![CDATA[<p>For work, I had a piece of code that needed to calculate if a certain date fell in between two other days. So I started out writing out this big long function to calculate if a date fell first within the same year as either of the two dates, and if so within the two months, and within the two days. It was ugly, inaccurate, complex and just plain stupid of me to do it that way.</p><p
class="refname">I knew there had to be an easier way so off to <a
title="PHP.net" href="http://us.php.net/">PHP.net</a> I went and sure enough there is <a
title="PHP.net: strtotime" href="http://us.php.net/manual/en/function.strtotime.php">strtotime</a>. Strtotime converts a string into a Unix timestamp. Turning my function into this:</p><p><code>function in_between_two_dates($first_date, $second_date, $third_date)<br
/> {<br
/> if(strtotime($first_date) &gt;= strtotime($second_date) &amp;&amp; strtotime($first_date) &lt;= strtotime($third_date) )<br
/> { return true; }<br
/> else return false;<br
/> }</code></p><p>Remember when in doubt: KISS (Keep it simple stupid).</p> ]]></content:encoded> <wfw:commentRss>http://www.yostivanich.com/2009/01/27/the-complex-made-simple/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 7/16 queries in 0.059 seconds using disk

Served from: www.yostivanich.com @ 2010-09-06 14:24:25 -->