<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Handling timezone conversion with PHP DateTime</title>
	<atom:link href="http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/</link>
	<description>Real software development</description>
	<lastBuildDate>Fri, 03 Feb 2012 10:34:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Nick</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-2959</link>
		<dc:creator><![CDATA[Nick]]></dc:creator>
		<pubDate>Sat, 21 Jan 2012 12:34:51 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-2959</guid>
		<description><![CDATA[Thanks for this]]></description>
		<content:encoded><![CDATA[<p>Thanks for this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vibha</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-2667</link>
		<dc:creator><![CDATA[Vibha]]></dc:creator>
		<pubDate>Wed, 19 Oct 2011 09:19:03 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-2667</guid>
		<description><![CDATA[Hi,

Thanx for the script,

I am showing server time and client time both on a page, used different variables. Script works fine in Firefox and Chrome, but in Safari, IE9 and Opera, it is not working, either or both times are not showing.
Please help]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanx for the script,</p>
<p>I am showing server time and client time both on a page, used different variables. Script works fine in Firefox and Chrome, but in Safari, IE9 and Opera, it is not working, either or both times are not showing.<br />
Please help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-2208</link>
		<dc:creator><![CDATA[Gary]]></dc:creator>
		<pubDate>Mon, 02 May 2011 01:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-2208</guid>
		<description><![CDATA[Thanks for this. I found the information and technique very useful.]]></description>
		<content:encoded><![CDATA[<p>Thanks for this. I found the information and technique very useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Williams</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-2195</link>
		<dc:creator><![CDATA[Richard Williams]]></dc:creator>
		<pubDate>Tue, 19 Apr 2011 18:11:19 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-2195</guid>
		<description><![CDATA[This worked fine for me.

Thanks for a good tutorial, pointed me in the right direction after going mad with bugs in PEAR Date.

I&#039;ve written up a simple function based on Josh&#039;s script...

http://richardwillia.ms/blog/2011/04/time-zone-conversion-using-datetime-class/]]></description>
		<content:encoded><![CDATA[<p>This worked fine for me.</p>
<p>Thanks for a good tutorial, pointed me in the right direction after going mad with bugs in PEAR Date.</p>
<p>I&#8217;ve written up a simple function based on Josh&#8217;s script&#8230;</p>
<p><a href="http://richardwillia.ms/blog/2011/04/time-zone-conversion-using-datetime-class/" rel="nofollow">http://richardwillia.ms/blog/2011/04/time-zone-conversion-using-datetime-class/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: arpatech</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-2099</link>
		<dc:creator><![CDATA[arpatech]]></dc:creator>
		<pubDate>Mon, 28 Mar 2011 17:15:21 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-2099</guid>
		<description><![CDATA[works for me.

setTimezone(new DateTimeZone(&#039;Asia/Manila&#039;));
echo $myDateTime-&gt;format(&#039;Y-m-d H:i&#039;);
?&gt;]]></description>
		<content:encoded><![CDATA[<p>works for me.</p>
<p>setTimezone(new DateTimeZone(&#8216;Asia/Manila&#8217;));<br />
echo $myDateTime-&gt;format(&#8216;Y-m-d H:i&#8217;);<br />
?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-1908</link>
		<dc:creator><![CDATA[Jeff]]></dc:creator>
		<pubDate>Sat, 12 Feb 2011 03:02:34 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-1908</guid>
		<description><![CDATA[I see a lot of people have already commented more or less what I was going to say -- it&#039;s much easier to use the setTimezone() method.  However I&#039;d like to point out that it&#039;s not only easier, it&#039;s really the way you have to do it (if you want it to work).  First off, the approach your suggesting only appears to work because you happen to be calculating your offset against a DateTime object which happens to be using the GMT timezone.  getOffset() always returns the offset from GMT, regardless of the timezone set on the DateTime object you use.  In fact, the only reason you need the DateTime object is because that world time is used to determine what the offset is -- The offset changes for TimeZones which follow daylight savings time and depending on what time of the year it is, the offset will change.
Mostly I want to point out though that your method of changing the time using the offset will leave you with a new DateTime object that has the wrong time.  Or rather it will have the right time, but the wrong TimeZone.  Worse it won&#039;t necessarily be the right time -- if you happen to offset the time across a clock change (spring forward, fall back) you&#039;ll end up with the wrong time and the wrong timezone.  
Here&#039;s what I&#039;m getting at.  Suppose the following time
date_create(&#039;2011-03-13T01:30&#039;, timezone_open(&#039;America/Chicago&#039;));
That&#039;s just 30 minutes before the clocks get turned forward.   If you add an hour with the following line
$sometime-&gt;add(date_interval_create_from_date_string(&#039;1 hour&#039;));
The resulting time is actually 3:30am because the hour from 2-3am doesn&#039;t exist.  Also, the clocks in the US all change at 2am based on local time, so strangely enough, in the fall you end up with a situation where 2:30am in Chicago is actually the second 2:30am in New York.  
If you use the setTimezone method though you&#039;ll find that your times always change consistently because under the covers they&#039;re always tracking UTC (GMT).]]></description>
		<content:encoded><![CDATA[<p>I see a lot of people have already commented more or less what I was going to say &#8212; it&#8217;s much easier to use the setTimezone() method.  However I&#8217;d like to point out that it&#8217;s not only easier, it&#8217;s really the way you have to do it (if you want it to work).  First off, the approach your suggesting only appears to work because you happen to be calculating your offset against a DateTime object which happens to be using the GMT timezone.  getOffset() always returns the offset from GMT, regardless of the timezone set on the DateTime object you use.  In fact, the only reason you need the DateTime object is because that world time is used to determine what the offset is &#8212; The offset changes for TimeZones which follow daylight savings time and depending on what time of the year it is, the offset will change.<br />
Mostly I want to point out though that your method of changing the time using the offset will leave you with a new DateTime object that has the wrong time.  Or rather it will have the right time, but the wrong TimeZone.  Worse it won&#8217;t necessarily be the right time &#8212; if you happen to offset the time across a clock change (spring forward, fall back) you&#8217;ll end up with the wrong time and the wrong timezone.<br />
Here&#8217;s what I&#8217;m getting at.  Suppose the following time<br />
date_create(&#8217;2011-03-13T01:30&#8242;, timezone_open(&#8216;America/Chicago&#8217;));<br />
That&#8217;s just 30 minutes before the clocks get turned forward.   If you add an hour with the following line<br />
$sometime-&gt;add(date_interval_create_from_date_string(&#8217;1 hour&#8217;));<br />
The resulting time is actually 3:30am because the hour from 2-3am doesn&#8217;t exist.  Also, the clocks in the US all change at 2am based on local time, so strangely enough, in the fall you end up with a situation where 2:30am in Chicago is actually the second 2:30am in New York.<br />
If you use the setTimezone method though you&#8217;ll find that your times always change consistently because under the covers they&#8217;re always tracking UTC (GMT).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-1738</link>
		<dc:creator><![CDATA[James]]></dc:creator>
		<pubDate>Tue, 07 Dec 2010 14:57:03 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-1738</guid>
		<description><![CDATA[Very useful, thanks, just put Timezone handling into our open source project :-)]]></description>
		<content:encoded><![CDATA[<p>Very useful, thanks, just put Timezone handling into our open source project :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Skibbler Elf</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-1354</link>
		<dc:creator><![CDATA[Skibbler Elf]]></dc:creator>
		<pubDate>Sat, 30 Oct 2010 04:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-1354</guid>
		<description><![CDATA[This post has helped a ton.  It does help to know your user&#039;s timezone...then you can figure the offset and store the correct time (most likely UTC) in your dB.

Ciao]]></description>
		<content:encoded><![CDATA[<p>This post has helped a ton.  It does help to know your user&#8217;s timezone&#8230;then you can figure the offset and store the correct time (most likely UTC) in your dB.</p>
<p>Ciao</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GMTSlider.com</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-1261</link>
		<dc:creator><![CDATA[GMTSlider.com]]></dc:creator>
		<pubDate>Tue, 28 Sep 2010 12:21:03 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-1261</guid>
		<description><![CDATA[That&#039;s exactly the code i was looking for so long! Thanks!]]></description>
		<content:encoded><![CDATA[<p>That&#8217;s exactly the code i was looking for so long! Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Automatic timezone conversion with JavaScript &#171; Boxed Ice Blog</title>
		<link>http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/#comment-1215</link>
		<dc:creator><![CDATA[Automatic timezone conversion with JavaScript &#171; Boxed Ice Blog]]></dc:creator>
		<pubDate>Fri, 03 Sep 2010 09:58:55 +0000</pubDate>
		<guid isPermaLink="false">http://boxedice.wordpress.com/?p=31#comment-1215</guid>
		<description><![CDATA[[...] 3, 2010   tags: dates, javascript, jquery, js, timezones by David Mytton   Timezones are a pain to deal with as a programmer but our server monitoring service, Server Density, has handled them for some time. It requires you [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 3, 2010   tags: dates, javascript, jquery, js, timezones by David Mytton   Timezones are a pain to deal with as a programmer but our server monitoring service, Server Density, has handled them for some time. It requires you [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

