<?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>Web 3.0, 6 Bladed Razors, 7 Minute Abs &#187; Dates</title>
	<atom:link href="http://www.zachleat.com/web/tag/dates/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zachleat.com/web</link>
	<description></description>
	<lastBuildDate>Fri, 30 Jul 2010 01:59:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Yet Another Pretty Date JavaScript</title>
		<link>http://www.zachleat.com/web/2008/03/23/yet-another-pretty-date-javascript/</link>
		<comments>http://www.zachleat.com/web/2008/03/23/yet-another-pretty-date-javascript/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 02:53:34 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2008/03/23/yet-another-pretty-date-javascript/</guid>
		<description><![CDATA[I can&#8217;t let this Pretty Date thing go. I decided to use a modification of John Resig&#8217;s Pretty Date JavaScript implementation written by Dean Landolt and shared in the comments on John&#8217;s page. The script was an obvious choice for the next iteration of Alarmd, which is nearing completion as I type. The more I [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t let this Pretty Date thing go.  I decided to use a modification of <a href="http://ejohn.org/blog/javascript-pretty-date/">John Resig&#8217;s Pretty Date JavaScript implementation</a> written by Dean Landolt and shared in the comments on John&#8217;s page.  The script was an obvious choice for the next iteration of <a href="http://www.zachleat.com/web/2007/06/18/wake-up-to-youtube-on-my-internet-alarm-clock/">Alarmd</a>, which is nearing completion as I type.</p>
<p>The more I used <a href="http://deanlandolt.com/archives/163">Dean Landolt&#8217;s script</a>, the more problems I began to see with his implementation.  It was a good start, but definitely had bugs.  His assumptions translating from integer second differences to human readable labels stretched too far at times (there is an error in logic to say anything between 24 hours and 48 hours from now can be labeled &#8220;Tomorrow&#8221;), and he was a bit loose with his difference categories (assumed average month length was 28 days, and always used Math.floor instead of rounding &#8212; 47 hours from now would be labeled &#8220;1 Day&#8221;).  It was great code otherwise, and I definitely liked the way he used the while loop to run through the comparisons.</p>
<p>So, I&#8217;ve cleaned up his great start, and am releasing it to the world in the spirit of cooperation and open sauce.  You just read that typo out loud didn&#8217;t you?</p>
<p><strong>Download</strong>: <a href="http://www.zachleat.com/Lib/jquery/humane.js">Yet Another Pretty Date Implementation</a> (2 KB)</p>
<p><strong>Update</strong>: Dates for this script must have a specific <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO8601 format</a>: <em>YYYY-MM-DDTHH:MM:SSZ</em> (in UTC) where T and Z are literals.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2008/03/23/yet-another-pretty-date-javascript/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>PHP Pretty Date</title>
		<link>http://www.zachleat.com/web/2008/02/10/php-pretty-date/</link>
		<comments>http://www.zachleat.com/web/2008/02/10/php-pretty-date/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 21:13:21 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[Propel]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2008/02/10/php-pretty-date/</guid>
		<description><![CDATA[This class is pretty much a direct port of John Resig&#8217;s JavaScript Pretty Date to PHP 5. A few notes: Requires PHP >= 5.10, due to the usage of PHP&#8217;s new DateTimeclass. The new DateTime object parses strings using PHP&#8217;s strtotime, so you don&#8217;t need to pass in an ISO8601 formatted date, as in JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p>This class is pretty much a direct port of <a href="http://ejohn.org/blog/javascript-pretty-date/">John Resig&#8217;s JavaScript Pretty Date</a> to PHP 5.  A few notes:</p>
<ul>
<li>Requires PHP >= 5.10, due to the usage of PHP&#8217;s new <a href="http://us3.php.net/manual/en/function.date-create.php">DateTime</a>class.</li>
<li>The new DateTime object parses strings using PHP&#8217;s <a href="http://us3.php.net/manual/en/function.strtotime.php">strtotime</a>, so you don&#8217;t need to pass in an ISO8601 formatted date, as in JavaScript Pretty Date. Try &#8220;now&#8221;, or &#8220;next Wednesday&#8221;, or &#8220;+2 weeks 4 days 23 hours 9 seconds&#8221;.</li>
<li>Extended to handle Months and Years in the past (JavaScript version only goes to weeks)</li>
</ul>
<p>Usage:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// pass in a String DateTime, compared to another String DateTime (defaults to now)</span>
<span style="color: #000088;">$myString</span> <span style="color: #339933;">=</span> Date_Difference<span style="color: #339933;">::</span><span style="color: #004000;">getStringResolved</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-7 weeks'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myString</span> <span style="color: #339933;">=</span> Date_Difference<span style="color: #339933;">::</span><span style="color: #004000;">getStringResolved</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-7 weeks'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'+1 week'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// pass in a DateTime object, compared to another DateTime object (defaults to now)</span>
<span style="color: #666666; font-style: italic;">// useful with the Propel ORM, which uses DateTime objects internally.</span>
<span style="color: #000088;">$myString</span> <span style="color: #339933;">=</span> Date_Difference<span style="color: #339933;">::</span><span style="color: #004000;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-7 weeks'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myString</span> <span style="color: #339933;">=</span> Date_Difference<span style="color: #339933;">::</span><span style="color: #004000;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-7 weeks'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'+1 week'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="http://www.zachleat.com/Projects/phpPrettyDate/Date_Difference.phps">Download PHP Pretty Date</a> (PHP 5.10+, 1.86KB)<br />
<a href="http://www.zachleat.com/Projects/phpPrettyDate/Date_Difference.phps">http://www.zachleat.com/Projects/phpPrettyDate/Date_Difference.phps</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2008/02/10/php-pretty-date/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
