<?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: Looking at PHP5&#8242;s DateTime and DateTimeZone</title>
	<atom:link href="http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/feed/" rel="self" type="application/rss+xml" />
	<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 30 Jan 2012 22:28:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: ??????? &#187; [Web] ????</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-800260</link>
		<dc:creator>??????? &#187; [Web] ????</dc:creator>
		<pubDate>Wed, 25 Nov 2009 02:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-800260</guid>
		<description>&lt;p&gt;[...] Looking at PHP5&#8217;s DateTime and DateTimeZone (IE only) [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] Looking at PHP5&#8217;s DateTime and DateTimeZone (IE only) [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Heimburg</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-614084</link>
		<dc:creator>Eric Heimburg</dc:creator>
		<pubDate>Wed, 19 Nov 2008 05:20:32 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-614084</guid>
		<description>&lt;p&gt;Hey I think I found them! They aren&#039;t documented at all; they are just mirrored in the docs for the old functions. Almost as if to say &quot;you can use this if you want, but the functions are the right way to do it.&quot; I&#039;ll take the hint.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hey I think I found them! They aren&#8217;t documented at all; they are just mirrored in the docs for the old functions. Almost as if to say &#8220;you can use this if you want, but the functions are the right way to do it.&#8221; I&#8217;ll take the hint.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Heimburg</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-614081</link>
		<dc:creator>Eric Heimburg</dc:creator>
		<pubDate>Wed, 19 Nov 2008 05:18:39 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-614081</guid>
		<description>&lt;p&gt;There are no docs for DateTime or DateTimeZone. Maybe they existed on the page you linked to once, but they no longer exist. Anywhere. On the internet. At all. It&#039;s very frustrating. &lt;/p&gt;

&lt;p&gt;I consider these objects dead unless they bother documenting them. An undocumented object is exactly as useless as no object at all.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>There are no docs for DateTime or DateTimeZone. Maybe they existed on the page you linked to once, but they no longer exist. Anywhere. On the internet. At all. It&#8217;s very frustrating. </p>

<p>I consider these objects dead unless they bother documenting them. An undocumented object is exactly as useless as no object at all.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Phil Oertel</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-595311</link>
		<dc:creator>Phil Oertel</dc:creator>
		<pubDate>Thu, 30 Oct 2008 19:30:50 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-595311</guid>
		<description>&lt;p&gt;Great article. I landed here trying to find out how to turn a birthday into an age and after finding PHP&#039;s own documentation bizarrely un-helpful. You&#039;ve written the definitive article about PHP&#039;s handling of time. And I still can&#039;t do what I want to do.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Great article. I landed here trying to find out how to turn a birthday into an age and after finding PHP&#8217;s own documentation bizarrely un-helpful. You&#8217;ve written the definitive article about PHP&#8217;s handling of time. And I still can&#8217;t do what I want to do.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Hurst</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-411012</link>
		<dc:creator>Pete Hurst</dc:creator>
		<pubDate>Thu, 03 Jul 2008 09:34:26 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-411012</guid>
		<description>&lt;p&gt;This article highlights all the reasons why PHP sucks.&lt;/p&gt;

&lt;p&gt;&quot;Let&#039;s create a great new object-oriented DateTime system!&quot;&lt;/p&gt;

&lt;p&gt;&quot;Let&#039;s not give it any useful new functionality, and let&#039;s just use it as a wrapper object around some already-existing and inconsistently-implemented functions!&quot;&lt;/p&gt;

&lt;p&gt;&quot;People will get mad if they can&#039;t do EVERYTHING from global functions, so we&#039;d better not actually make dates easier to work with in this class! The functional guys would only get jealous of the OO guys...&quot;&lt;/p&gt;

&lt;p&gt;Really, in the world of modern languages, PHP sucks big time. It&#039;s like 10 years old. Various attempts in PHP5 to make it &quot;more OO&quot; only serve to show that Zend don&#039;t actually understand OO.&lt;/p&gt;

&lt;p&gt;Anyway: thanks for a good article. Unfortunately I&#039;m still having to work in PHP and needing all the support I can get!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This article highlights all the reasons why PHP sucks.</p>

<p>&#8220;Let&#8217;s create a great new object-oriented DateTime system!&#8221;</p>

<p>&#8220;Let&#8217;s not give it any useful new functionality, and let&#8217;s just use it as a wrapper object around some already-existing and inconsistently-implemented functions!&#8221;</p>

<p>&#8220;People will get mad if they can&#8217;t do EVERYTHING from global functions, so we&#8217;d better not actually make dates easier to work with in this class! The functional guys would only get jealous of the OO guys&#8230;&#8221;</p>

<p>Really, in the world of modern languages, PHP sucks big time. It&#8217;s like 10 years old. Various attempts in PHP5 to make it &#8220;more OO&#8221; only serve to show that Zend don&#8217;t actually understand OO.</p>

<p>Anyway: thanks for a good article. Unfortunately I&#8217;m still having to work in PHP and needing all the support I can get!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Timezone conversions with php &#171; More content</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-306637</link>
		<dc:creator>Timezone conversions with php &#171; More content</dc:creator>
		<pubDate>Mon, 14 Apr 2008 02:30:11 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-306637</guid>
		<description>&lt;p&gt;[...] used some of the code examples by Kellan Elliott-McCrea at LaughingMeme to get me on the way to building this. His page is a much larger discussion surrounding date and [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] used some of the code examples by Kellan Elliott-McCrea at LaughingMeme to get me on the way to building this. His page is a much larger discussion surrounding date and [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Ford</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-285776</link>
		<dc:creator>Pete Ford</dc:creator>
		<pubDate>Thu, 20 Mar 2008 16:39:14 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-285776</guid>
		<description>&lt;p&gt;Comparison seems to work directly - at least on PHP 5.2.x:&lt;/p&gt;

&lt;p&gt;$yesterday = new DateTime(&#039;yesterday&#039;);
$tomorrow = new DateTime(&#039;tomorrow&#039;);
$now = new DateTime();
// &#039;less-than&#039; certainly works:
echo &#039;Yesterday is before today? &#039;.($yesterday &lt; $now ? &#039;yes&#039;:&#039;no&#039;).&quot;\n&quot;;
// So does &#039;not-equals&#039;
echo &#039;Today is not yesterday? &#039;.($yesterday != $now ? &#039;yes&#039;:&#039;no&#039;).&quot;\n&quot;;
// and &#039;greater-than&#039;
echo &#039;Tomorrow is after today? &#039;.($tomorrow &gt; $now ? &#039;yes&#039;:&#039;no&#039;).&quot;\n&quot;;&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;Yesterday is before today? yes
Today is not yesterday? yes
Tomorrow is after today? yes&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Comparison seems to work directly &#8211; at least on PHP 5.2.x:</p>

<p>$yesterday = new DateTime(&#8216;yesterday&#8217;);
$tomorrow = new DateTime(&#8216;tomorrow&#8217;);
$now = new DateTime();
// &#8216;less-than&#8217; certainly works:
echo &#8216;Yesterday is before today? &#8216;.($yesterday &lt; $now ? &#8216;yes&#8217;:'no&#8217;).&#8221;\n&#8221;;
// So does &#8216;not-equals&#8217;
echo &#8216;Today is not yesterday? &#8216;.($yesterday != $now ? &#8216;yes&#8217;:'no&#8217;).&#8221;\n&#8221;;
// and &#8216;greater-than&#8217;
echo &#8216;Tomorrow is after today? &#8216;.($tomorrow &gt; $now ? &#8216;yes&#8217;:'no&#8217;).&#8221;\n&#8221;;</p>

<p>Output:</p>

<p>Yesterday is before today? yes
Today is not yesterday? yes
Tomorrow is after today? yes</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Roberto Innocenti</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-235580</link>
		<dc:creator>Roberto Innocenti</dc:creator>
		<pubDate>Thu, 07 Feb 2008 17:10:00 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-235580</guid>
		<description>&lt;p&gt;With Php 5.2.5 SetDate(null,null,1) produce Year=0, month=1 , day=1;
Solution:
$datetmp-&gt;setDate($datetmp-&gt;format(&#039;Y&#039;), $datetmp-&gt;format(&#039;m&#039;), &#039;1&#039;);&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>With Php 5.2.5 SetDate(null,null,1) produce Year=0, month=1 , day=1;
Solution:
$datetmp-&gt;setDate($datetmp-&gt;format(&#8216;Y&#8217;), $datetmp-&gt;format(&#8216;m&#8217;), &#8217;1&#8242;);</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-233572</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Wed, 06 Feb 2008 09:29:35 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-233572</guid>
		<description>&lt;p&gt;You can apparently pass in a UNIX TIMESTAMP thusly:&lt;/p&gt;

&lt;p&gt;$date = new DateTime(&quot;@1192951100&quot;);
echo $date-&gt;format(&#039;Y-m-d H:i&#039;);&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You can apparently pass in a UNIX TIMESTAMP thusly:</p>

<p>$date = new DateTime(&#8220;@1192951100&#8243;);
echo $date-&gt;format(&#8216;Y-m-d H:i&#8217;);</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Cezary Okupski</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-130419</link>
		<dc:creator>Cezary Okupski</dc:creator>
		<pubDate>Sat, 20 Oct 2007 06:52:02 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-130419</guid>
		<description>&lt;p&gt;For information on setISODate read http://en.wikipedia.org/wiki/ISO&lt;em&gt;week&lt;/em&gt;date. Week dates are a part of ISO 8601 specification although they probably have less significance to their standard month counterparts. I guess this isn&#039;t a cultural difference as you suggest, I don&#039;t believe that anyone uses it on a daily basis, although I see a practical use for it. Let&#039;s assume that you want your program to understand a sentence like &quot;see you next week&quot; - it would know unambiguously that there will be a meating when the week equals to &quot;2007-W43&quot;.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>For information on setISODate read <a href="http://en.wikipedia.org/wiki/ISO" rel="nofollow">http://en.wikipedia.org/wiki/ISO</a><em>week</em>date. Week dates are a part of ISO 8601 specification although they probably have less significance to their standard month counterparts. I guess this isn&#8217;t a cultural difference as you suggest, I don&#8217;t believe that anyone uses it on a daily basis, although I see a practical use for it. Let&#8217;s assume that you want your program to understand a sentence like &#8220;see you next week&#8221; &#8211; it would know unambiguously that there will be a meating when the week equals to &#8220;2007-W43&#8243;.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Fischer</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-124400</link>
		<dc:creator>Fischer</dc:creator>
		<pubDate>Thu, 11 Oct 2007 20:27:38 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-124400</guid>
		<description>&lt;p&gt;Instructions on how to update PHP&#039;s timezonedb&lt;/p&gt;

&lt;p&gt;http://fischer.tecnologia.ws/en/node/1&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Instructions on how to update PHP&#8217;s timezonedb</p>

<p><a href="http://fischer.tecnologia.ws/en/node/1" rel="nofollow">http://fischer.tecnologia.ws/en/node/1</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: ehh</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-122446</link>
		<dc:creator>ehh</dc:creator>
		<pubDate>Mon, 08 Oct 2007 18:29:21 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-122446</guid>
		<description>&lt;p&gt;It is php 5.x changelog
In documentation of this class: PHP 5 &gt;= 5.1.0&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>It is php 5.x changelog
In documentation of this class: PHP 5 &gt;= 5.1.0</p>]]></content:encoded>
	</item>
	<item>
		<title>By: developercast.com &#187; LaughingMeme.com: Looking at PHP5&#8217;s DateTime and DateTimeZone</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-122347</link>
		<dc:creator>developercast.com &#187; LaughingMeme.com: Looking at PHP5&#8217;s DateTime and DateTimeZone</dc:creator>
		<pubDate>Mon, 08 Oct 2007 16:25:58 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-122347</guid>
		<description>&lt;p&gt;[...] As Martynas Jusevicius points out today, there&#8217;s a great little look at the new DateTime functionality that&#8217;s included with PHP5 to make working with dates even simpler.   There is something fundamentally brash, brazen even, to releasing a class named DateTime. [&#8230;] I&#8217;m going to bump my way through learning how to use this new DateTime lib, bringing all my preconceptions about how it should work. The odds of this being interesting to you is probably nil unless you&#8217;re in one or two very small cliques, feel free to read on, or browse away. [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] As Martynas Jusevicius points out today, there&#8217;s a great little look at the new DateTime functionality that&#8217;s included with PHP5 to make working with dates even simpler.   There is something fundamentally brash, brazen even, to releasing a class named DateTime. [&#8230;] I&#8217;m going to bump my way through learning how to use this new DateTime lib, bringing all my preconceptions about how it should work. The odds of this being interesting to you is probably nil unless you&#8217;re in one or two very small cliques, feel free to read on, or browse away. [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Paul G</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-19367</link>
		<dc:creator>Paul G</dc:creator>
		<pubDate>Mon, 12 Mar 2007 07:40:40 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-19367</guid>
		<description>&lt;p&gt;Thanks Kellan, I was afraid that would be the case. The other question I have is assuming the timezonedb is up to date (including DST), how can I use PHP to show the current time in any given timezone? For example, my server may be located in new york but I want to display the current time of other cities on the same page as well. Such as:&lt;/p&gt;

&lt;p&gt;New York - Mon 3:30 (DST)
Paris - Mon 8:30
Sydney - Mon 18:30 (DST)
San Francisco - Mon 0:30 (DST)
Tokyo - Mon 16:30
ETC...&lt;/p&gt;

&lt;p&gt;Is this wishful thinking in PHP or something very obvious to someone with more experience than me?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks Kellan, I was afraid that would be the case. The other question I have is assuming the timezonedb is up to date (including DST), how can I use PHP to show the current time in any given timezone? For example, my server may be located in new york but I want to display the current time of other cities on the same page as well. Such as:</p>

<p>New York &#8211; Mon 3:30 (DST)
Paris &#8211; Mon 8:30
Sydney &#8211; Mon 18:30 (DST)
San Francisco &#8211; Mon 0:30 (DST)
Tokyo &#8211; Mon 16:30
ETC&#8230;</p>

<p>Is this wishful thinking in PHP or something very obvious to someone with more experience than me?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: kellan</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-19003</link>
		<dc:creator>kellan</dc:creator>
		<pubDate>Sun, 11 Mar 2007 07:50:51 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-19003</guid>
		<description>&lt;p&gt;Paul I don&#039;t think you can.  MAMP doesn&#039;t ship with the necessary .h files to build PECLs (C based extensions), only PEAR modules.  &lt;/p&gt;

&lt;p&gt;MAMP is really for prototyping, not a longer term solution.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Paul I don&#8217;t think you can.  MAMP doesn&#8217;t ship with the necessary .h files to build PECLs (C based extensions), only PEAR modules.  </p>

<p>MAMP is really for prototyping, not a longer term solution.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Paul G</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-17821</link>
		<dc:creator>Paul G</dc:creator>
		<pubDate>Wed, 07 Mar 2007 21:12:47 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-17821</guid>
		<description>&lt;p&gt;Can anyone shed any light on how to update the PHP timezonedb in MAMP? I know the latest version is available at http://pecl.php.net/package/timezonedb/ and the description says it is a &quot;drop-in replacement&quot;, but I can&#039;t find any instructions on where or how to &quot;drop it in&quot;. Any help is appreciated by a grateful newbie.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Can anyone shed any light on how to update the PHP timezonedb in MAMP? I know the latest version is available at <a href="http://pecl.php.net/package/timezonedb/" rel="nofollow">http://pecl.php.net/package/timezonedb/</a> and the description says it is a &#8220;drop-in replacement&#8221;, but I can&#8217;t find any instructions on where or how to &#8220;drop it in&#8221;. Any help is appreciated by a grateful newbie.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Reynen</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-15382</link>
		<dc:creator>Scott Reynen</dc:creator>
		<pubDate>Wed, 28 Feb 2007 21:23:25 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-15382</guid>
		<description>&lt;p&gt;Right, the ability to improve the object doesn&#039;t suggest it shouldn&#039;t be better to begin with. But spare objects seem very PHP-like to me. Most PHP objects I see are just glorified functions, because most PHP developers are coming from a functional programming background, as is the language itself.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Right, the ability to improve the object doesn&#8217;t suggest it shouldn&#8217;t be better to begin with. But spare objects seem very PHP-like to me. Most PHP objects I see are just glorified functions, because most PHP developers are coming from a functional programming background, as is the language itself.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Macgirvin</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-15323</link>
		<dc:creator>Mike Macgirvin</dc:creator>
		<pubDate>Wed, 28 Feb 2007 18:41:12 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-15323</guid>
		<description>&lt;p&gt;Thanks Kellan - you&#039;ve saved me from a lot of my own investigative work. I still find the simplest date/time solution for PHP on the LAMP stack is to make use of the fact that Linux has Olson support in the OS. Why have two Olson DBs to maintain? &lt;/p&gt;

&lt;p&gt;For most everyday issues, use gmdate functions for storage and putenv(&#039;TZ=wherever&#039;) to make the local presentation correct and you&#039;re done. Converting a stored gmdate (say MySQL date/time format) to localtime for a given date string is a matter of appending &#039;+0000&#039; onto the SQL string, passing it through strtotime, and then use date() on the result. The +0000 forces strtotime into dealing with it as GMT instead of trying to act smart and adding your local offset. Should be easier, but that ain&#039;t bad. &lt;/p&gt;

&lt;p&gt;I&#039;ve got a handy little function I found somewhere in the wild which implements a selector by recursively reading the contents of the zoneinfo dir, sorting it and turning into an HTML SELECT form.&lt;/p&gt;

&lt;p&gt;For complicated date/time comparisons/operations across different zones, the only gotcha&#039; is that you&#039;ve got to put TZ in the environment for each zone you need to work with and change it back to the default when done. &lt;/p&gt;

&lt;p&gt;I hear Windows/PHP users have a heck of a time doing this, but this usually doesn&#039;t concern me.&lt;/p&gt;

&lt;p&gt;It would be nice if the new classes made this even easier, but from my reading - they haven&#039;t. The only real advantage I can see is that if you&#039;re willing to go through the work, you can have a portable implementation that will run on a Windows box.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks Kellan &#8211; you&#8217;ve saved me from a lot of my own investigative work. I still find the simplest date/time solution for PHP on the LAMP stack is to make use of the fact that Linux has Olson support in the OS. Why have two Olson DBs to maintain? </p>

<p>For most everyday issues, use gmdate functions for storage and putenv(&#8216;TZ=wherever&#8217;) to make the local presentation correct and you&#8217;re done. Converting a stored gmdate (say MySQL date/time format) to localtime for a given date string is a matter of appending &#8216;+0000&#8242; onto the SQL string, passing it through strtotime, and then use date() on the result. The +0000 forces strtotime into dealing with it as GMT instead of trying to act smart and adding your local offset. Should be easier, but that ain&#8217;t bad. </p>

<p>I&#8217;ve got a handy little function I found somewhere in the wild which implements a selector by recursively reading the contents of the zoneinfo dir, sorting it and turning into an HTML SELECT form.</p>

<p>For complicated date/time comparisons/operations across different zones, the only gotcha&#8217; is that you&#8217;ve got to put TZ in the environment for each zone you need to work with and change it back to the default when done. </p>

<p>I hear Windows/PHP users have a heck of a time doing this, but this usually doesn&#8217;t concern me.</p>

<p>It would be nice if the new classes made this even easier, but from my reading &#8211; they haven&#8217;t. The only real advantage I can see is that if you&#8217;re willing to go through the work, you can have a portable implementation that will run on a Windows box.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: kellan</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-15284</link>
		<dc:creator>kellan</dc:creator>
		<pubDate>Wed, 28 Feb 2007 16:37:39 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-15284</guid>
		<description>&lt;p&gt;Scott, absolutely.  &lt;/p&gt;

&lt;p&gt;And also define a a __toString method, and some accessors and mutators, and probably some convience methods for math.  Objects are wondeful!&lt;/p&gt;

&lt;p&gt;But as I was playing with the objects it was interesting to see how spare they were, how, un-PHP like.  Contrary to how it might seem at first PHP &lt;em&gt;does&lt;/em&gt; have a guiding aethestic (just like any other language) and we shouldn&#039;t discrad obviousness and easy to use just because objects have entered the scene.  And core PHP classes should model that good design.&lt;/p&gt;

&lt;p&gt;(Normally I&#039;d draw some parallel with Ruby here about how they have objects, but they&#039;re still simple and intuitive but Ruby&#039;s Date/Time/TimeZone stuff is a freakshow only slowly getting better)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Scott, absolutely.  </p>

<p>And also define a a __toString method, and some accessors and mutators, and probably some convience methods for math.  Objects are wondeful!</p>

<p>But as I was playing with the objects it was interesting to see how spare they were, how, un-PHP like.  Contrary to how it might seem at first PHP <em>does</em> have a guiding aethestic (just like any other language) and we shouldn&#8217;t discrad obviousness and easy to use just because objects have entered the scene.  And core PHP classes should model that good design.</p>

<p>(Normally I&#8217;d draw some parallel with Ruby here about how they have objects, but they&#8217;re still simple and intuitive but Ruby&#8217;s Date/Time/TimeZone stuff is a freakshow only slowly getting better)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Reynen</title>
		<link>http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/comment-page-1/#comment-15086</link>
		<dc:creator>Scott Reynen</dc:creator>
		<pubDate>Wed, 28 Feb 2007 04:04:48 +0000</pubDate>
		<guid isPermaLink="false">http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/#comment-15086</guid>
		<description>&lt;p&gt;You could always do something like this to make it work how you want:&lt;/p&gt;

&lt;p&gt;class BetterDateTime extends DateTime {
function setTimeZone( $tz ) { parent::setTimeZone( $tz ); return $this; }
function setDate( $year , $month , $day ) { parent::setDate( $year , $month , $day ); return $this; }
}&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You could always do something like this to make it work how you want:</p>

<p>class BetterDateTime extends DateTime {
function setTimeZone( $tz ) { parent::setTimeZone( $tz ); return $this; }
function setDate( $year , $month , $day ) { parent::setDate( $year , $month , $day ); return $this; }
}</p>]]></content:encoded>
	</item>
</channel>
</rss>

