<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Tue, 22 May 2012 13:16:30 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Derick Rethans' Blog: To GMT or not to GMT]]></title>
      <guid>http://www.phpdeveloper.org/news/17611</guid>
      <link>http://www.phpdeveloper.org/news/17611</link>
      <description><![CDATA[<p>
In <a href="http://derickrethans.nl/gmt-being-tricky.html">this new post</a> to his site, <i>Derick Rethans</i> shows an instance of "GMT being tricky" when it comes to "UTC" versus "GMT" output from PHP's DateTime object.
</p>
<blockquote>
Earlier today, on twitter, @skoop asked: "dear #lazyweb, when I use DateTimeZone('GMT'), why does format('e') output UTC?" [...] As you can see [the example with a format of "e" on a DateTimeZone('GMT')] has UTC and not GMT as you might expect.
</blockquote>
<p>
<i>Derick</i> mentions that sometimes, systems require "GMT" instead of "UTC" in the output they're given. To work around this issue, he shows how to add a "type 2" timezone to the DateTime object by including it when you initialize the object (code samples included). Using alternative methods, you can add these "type 2" timezones in three ways - an offset in the initial string, using the abbreviation (like "EST" or "PST") and specifying the long version of the timezone (like "America/Montreal").
</p>]]></description>
      <pubDate>Thu, 01 Mar 2012 11:39:45 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Working with Dates and Times in PHP and MySQL]]></title>
      <guid>http://www.phpdeveloper.org/news/17608</guid>
      <link>http://www.phpdeveloper.org/news/17608</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial by <i>Sean Hudgston</i> about <a href="http://phpmaster.com/working-with-dates-and-times">working with dates and times</a> via the PHP date functions and how they cooperate with dates/times from a MySQL database.
</p>
<blockquote>
When working in any programming language, dealing with dates and time is often a trivial and simple task. That is, until time zones have to be supported. Fortunately, PHP has one of the most potent set of date/time tools that help you deal with all sorts of time-related issues: Unix timestamps, formatting dates for human consumption, displaying times with time zones, the difference between now and the second Tuesday of next month, etc. In this article I'll introduce you to the basics of PHP's time functions (time(), mktime(), and date()) and their object-oriented counterparts, and then take a look at MySQL dates and show you how to make them play nicely with PHP.
</blockquote>
<p>
His examples include how to get the current Unix time, formatting dates/times, making timestamps and working with the more powerful DateTime objects. On the MySQL front, he shows the result of a normal date select, one using the "unix_timestamp" function and how to shift the result based on the user's timezone.
</p>]]></description>
      <pubDate>Thu, 01 Mar 2012 08:51:47 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Davey Shafik's Blog: DateTime Timestamp Parsing]]></title>
      <guid>http://www.phpdeveloper.org/news/16882</guid>
      <link>http://www.phpdeveloper.org/news/16882</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Davey Shafik</i> looks at <a href="http://daveyshafik.com/archives/28101-datetime-timestamp-parsing.html">parsing dates with DateTime</a>, the <a href="http://php.net/datetime">new and improved</a> way to handle dates in PHP (well, not so new but definitely improved).
</p>
<blockquote>
As part of a recent project, I was tasked with taking timestamps returned by an API and displaying fuzzy dates in the final output (e.g. 3hrs ago, in 2 weeks, tomorrow). The timestamp format in question looks like: 2012-09-01T16:20:01-05:00 This format can be found in PHP as the DATE_ATOM or DateTime::ATOM constants, which contain the date() formatter string: Y-m-dTH:i:sP With this in hand, we can now easily parse the timestamp into a useful object.
</blockquote>
<p>
Parsing the date into a DateTime object is as easy as giving it the date string and telling it how it's formatted. Then you can do all sorts of fun things. He shows how to shift the timezone by name, by time increment - simple (like "1 hour") and more complex (like "1 hour 5 minutes 3 seconds"). You can find out more about the DateTime object <a href="http://php.net/datetime">in the PHP manual</a>.
</p>]]></description>
      <pubDate>Tue, 20 Sep 2011 11:24:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Christian Schaefer's Blog: Beware of the timezone! Working with PHP DateTime & Doctrine for MongoDB]]></title>
      <guid>http://www.phpdeveloper.org/news/16822</guid>
      <link>http://www.phpdeveloper.org/news/16822</link>
      <description><![CDATA[<p>
<i>Christian Schaefer</i> has a recent post pointing out a common frustration among developers of applications with NoSQL backends, specifically with Doctrine, MongoDB and PHP DateTime objects - <a href="http://test.ical.ly/2011/09/01/beware-of-the-timezone-working-with-php-datetime-and-doctrine-for-mongodb-can-cause-conflicts/">timezone conflicts</a>.
</p>
<blockquote>
I really like <a href="http://test.ical.ly/2011/03/25/how-to-select-for-a-specific-date-or-time-with-doctrine-2-0/">Doctrines way of dealing with dates and times</a>. Instead of passing timestamps around or strings with ISO date format it simply makes use of the PHP native type DateTime which provides all you really need to work with. PHPs interface to MongoDB however comes with its own MongoDate type which provides hardly any functionality compared to DateTime and it's not compatible with it. So what's the difference?
</blockquote>
<p>
In some of the <a href="http://test.ical.ly/2011/09/01/beware-of-the-timezone-working-with-php-datetime-and-doctrine-for-mongodb-can-cause-conflicts/#comments">comments to the post</a>, readers mention that the problem is bigger than just the tools used to work with the database, it's that databases usually don't care about timezones when working with date/time. There's also an interesting mention further down about <a href="http://www.lightcubesolutions.com/blog/?p=373">the timezone support MongoDB does have</a> and an example snippet ofo code that uses the support.
</p>]]></description>
      <pubDate>Tue, 06 Sep 2011 13:50:38 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Slawek Lukasiewicz's Blog: Working with date and time in object oriented way]]></title>
      <guid>http://www.phpdeveloper.org/news/16451</guid>
      <link>http://www.phpdeveloper.org/news/16451</link>
      <description><![CDATA[<p>
<i>Slawek Lukasiewicz</i> has a new post today about <a href="http://www.leftjoin.net/2011/06/working-with-date-and-time-in-object-oriented-way/">working with dates and times in PHP</a> on a more object-oriented fashion than in the more traditionally procedural way of just calling PHP date/time functions on the string values.
</p>
<blockquote>
Date and time manipulation in PHP is mostly connected with functions like: date, time or strtotime. They can be sufficient, but if we want to deal with dates like with objects - we can use DateTime class. DateTime class is not only straightforward wrapper for standard functions, it has a lot of additional features - for example timezones.
</blockquote>
<p>
He shows how to use the <a href="http://php.net/datetime">DateTime</a> functionality to return an object you can call several different methods on. He gives examples of the formatting call, comparing one DateTime object to another, how to update the date after the object's created, calculating the difference between two dates and iterating through a certain time period.
</p>]]></description>
      <pubDate>Fri, 10 Jun 2011 08:13:14 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[XPertDeveloper.com: Is Your PHP Application Affected by the Y2K38?]]></title>
      <guid>http://www.phpdeveloper.org/news/16341</guid>
      <link>http://www.phpdeveloper.org/news/16341</link>
      <description><![CDATA[<p>
On the XpertDeveloper.com site there's a post reminding you of an date could cause all sorts of problems with your PHP application - <a href="http://www.xpertdeveloper.com/2010/08/is-your-php-application-affected-by-the-y2k38/">the effects of the Y2K38 bug</a>.
</p>
<blockquote>
<a href="http://en.wikipedia.org/wiki/Year_2038_problem">Y2K38</a>, or the Unix Millennium Bug, affects PHP and many other languages and systems which use a signed 32-bit integer to signify dates as the number of seconds since 00:00:00 UTC on 1 January 1970. The furthest date which can be stored is 03:14:07 UTC on 19 January 2038. Beyond that, the left-most bit is set and the integer becomes a negative decimal number or a time prior to the epoch.
</blockquote>
<p>
If you're worried about your application's support for date and time handling, there's a pretty simple fix - replace your current handling with the <a href="http://php.net/datetime">DateTime</a> functionality. This handles them correctly.
</p>]]></description>
      <pubDate>Mon, 16 May 2011 09:22:18 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[James Cohen's Blog: Working with Date and Time in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16292</guid>
      <link>http://www.phpdeveloper.org/news/16292</link>
      <description><![CDATA[<p>
<i>James Cohen</i> has <a href="http://webmonkeyuk.wordpress.com/2011/05/04/working-with-date-and-time-in-php/">a new post to his blog</a> today looking at some of the built-in functionality that PHP has to work with dates and times including simple things like <a href="http://php.net/strtotime">strtotime</a> and the <a href="http://php.net/datetime">DateTime</a> feature.
</p>
<blockquote>
A lot of people ask questions relating to date and time in PHP. Here are some answers to the most commonly asked questions and common mistakes.
</blockquote>
<p>
He covers the differences between working with dates in strtotime, worrying about timezone settings and compares the strtotime/DateTime methods for formatting and returning dates, modifying dates, converting between timezones as well as finding the difference between two timezones. 
</p>]]></description>
      <pubDate>Wed, 04 May 2011 08:59:23 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Swan's Blog: SQL Server Driver for PHP Connection Options: ReturnDatesAsStrings]]></title>
      <guid>http://www.phpdeveloper.org/news/15876</guid>
      <link>http://www.phpdeveloper.org/news/15876</link>
      <description><![CDATA[<p>
<i>Brian Swan</i> has a new post to his blog today looking at one of the <a href="http://blogs.msdn.com/b/brian_swan/archive/2011/02/08/sql-server-driver-for-php-connection-options-returndatesasstrings.aspx">connection options for the SQL Server driver</a> in PHP - the "ReturnDatesAsStrings" setting that can make handling date and time information simpler for PHP.
</p>
<blockquote>
This is short post to address a frustration I've seen mentioned on Twitter and in forums a lot: By default, the SQL Server Driver for PHP returns <a href="http://msdn.microsoft.com/en-us/library/ms187819.aspx">datetime</a> columns as <a href="http://www.php.net/manual/en/class.datetime.php">PHP DateTime</a> objects, not strings. This can be especially frustrating if you are not aware of the ReturnDatesAsStrings connection option. By simply setting this option to 1 (or true) when you connect to the server, datetime columns will be returned as strings.
</blockquote>
<p>
He includes some sample code showing how to use the setting (as a part of the settings array passed in to sqlsrv_connect) and the resulting array key from the fetched results on his sample table. This just gives you one more option for handling dates in your SQL Server-based application, especially if you don't need the full DateTIme object's functionality.
</p>]]></description>
      <pubDate>Wed, 09 Feb 2011 08:45:28 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DZone.com: Date and time in PHP 5]]></title>
      <guid>http://www.phpdeveloper.org/news/15522</guid>
      <link>http://www.phpdeveloper.org/news/15522</link>
      <description><![CDATA[<p>
New on the Web Builder Zone today, there's <a href="http://css.dzone.com/articles/date-and-time-php-5">an article about DateTime</a> in PHP5 from <i>Giorgio Sironi</i> introducing you to this very handy built-in feature.
</p>
<blockquote>
PHP has made some progress here as well, for example with the Standard Php Library and its interfaces. Though, the SPL is incomplete and oriented to performance more than to object-oriented programming: take a look at the SplStack and SplQueue implementation containing 20 different methods to get the idea. However a little gem is shipped with each PHP installation: the datetime extension, which contains the DateTime class and its siblings. Ideally, everything you can do with date_* functions, you can do it with this class.
</blockquote>
<p>
He includes some code that shows the DateTime object in action as a part of a PHPUnit test case - adding days, subtracting months, date difference and its support of operator overloading. There's also mention of Doctrine's native support for the extension.
</p>]]></description>
      <pubDate>Wed, 01 Dec 2010 13:58:03 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[SitePoint PHP Blog: Is Your PHP Application Affected by the Y2K38 Bug?]]></title>
      <guid>http://www.phpdeveloper.org/news/15009</guid>
      <link>http://www.phpdeveloper.org/news/15009</link>
      <description><![CDATA[<p>
On the SitePoint PHP blog today they pose a question to all PHP developers out there - is your application <a href="http://www.sitepoint.com/blogs/2010/08/24/is-your-php-application-affected-by-the-y2k38-bug/">affected by the Y2K38 bug</a>?
</p>
<blockquote>
I don't want to be too alarmist, but try running the [given] PHP code on your system. [...] With luck, you'll see "Wednesday 1 February 2040 00:00" displayed in your browser. If you're seeing a date in the late 60's or early 70's, your PHP application may be at risk from the Y2K38 bug!
</blockquote>
<p>
The bug, caused by a 32-bit operating system, can be helped by running the application on a 64-bit platform (it's due to the limitation of integer size), but there is another option - the <a href="http://www.php.net/manual/en/class.datetime.php">DateTime</a> class that handles dates and times differently than the just using the local time settings.
</p>]]></description>
      <pubDate>Tue, 24 Aug 2010 10:12:23 -0500</pubDate>
    </item>
  </channel>
</rss>

