<?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>Fri, 24 May 2013 23:30:44 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Gonzalo Ayuso: Handling dates with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/18540</guid>
      <link>http://www.phpdeveloper.org/news/18540</link>
      <description><![CDATA[<p>
In <a href="http://gonzalo123.com/2012/10/01/handling-dates-with-php/">this new post</a> to his site <i>Gonzalo Ayuso</i> introduces you to one of the more powerful parts of the PHP language - the <a href="http://php.net/datetime">DateTime</a> object.
</p>
<blockquote>
I've seen a lot of newbies (and not newbies) having problems handling dates in PHP (and even with SQL and another languages). When I see someone having problems with dates, I always ask the same question. I type in a text editor "27/11/2012&#8243; and I ask him: What is it? If your answer is "This is a date" you should continue reading the post.
</blockquote>
<p>
He talks about how the DateTime functionality replaces (much more effectively) some of the older date handling methods in PHP. He includes a few examples comparing it to <a href="http://php.net/date">date</a> and showing how it can be used to compare dates. He includes a "Dummy" class he mocked up to show how you could work with DateTime to get/set formatted dates, set the format to use and get the current format. As always, he also provides tests for the code as well.
</p>
<p>
This is just the tip of the iceberg as to what DateTime can do, so I'd suggest checking out <a href="http://php.net/manual/book.datetime.php">the manual page</a> for it to see the full list of features.
</p>]]></description>
      <pubDate>Tue, 02 Oct 2012 08:41:09 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell: PHP 5.4 Benchmarks]]></title>
      <guid>http://www.phpdeveloper.org/news/18247</guid>
      <link>http://www.phpdeveloper.org/news/18247</link>
      <description><![CDATA[<p>
In <a href="http://www.lornajane.net/posts/2012/php-5-4-benchmarks">this quick post</a> to her site, <i>Lorna Mitchell</i> shares some of the benchmark results she found when doing some tests with the latest version of PHP - 5.4.
</p>
<blockquote>
Today I'm giving my first ever talk at OSCON - about PHP 5.4 (I'll also be giving my second ever talk at OSCON, about RESTful services; it's a busy day!). My talk includes some benchmarks which I thought I'd also share here. [...] This graph shows the performance of four versions of PHP (because the bench.php script that lives in the php source tree didn't appear until 5.1). The axis up the left is the time it took to run the benchmark script - so a smaller number is better news.
</blockquote>
<p>
You can see a <a href="https://chart.googleapis.com/chart?cht=bvs&chs=650x300&chma=30,30,30,30&chbh=50,20&chxt=x,y,x&chxl=0:|5.1.6|5.2.17|5.3.14|5.4.4|2:||PHP%20version&chd=t:3.97,4.1,2.8,2.25&chds=0,5&chxr=1,0,5&chco=991d66|c57fa3|bebcb9|52b4b2&chts=000000,24&chxs=0,,18|1,,18|2,,18">dramatic difference</a> between even just the latest in the PHP 5.3.x series in the 5.4 results. There's also a table with the details of each of her 10 executions of the "bench.php" script showing the results of the time spent to run the script on four different PHP versions.
</p>]]></description>
      <pubDate>Thu, 19 Jul 2012 09:54:42 -0500</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[Gonzalo Ayuso's Blog: Checking the performance of PHP exceptions]]></title>
      <guid>http://www.phpdeveloper.org/news/17403</guid>
      <link>http://www.phpdeveloper.org/news/17403</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has a new post to his blog today looking at <a href="http://gonzalo123.wordpress.com/2012/01/16/checking-the-performance-of-php-exceptions/">the performance of PHP exceptions</a> and how it could effect your application's overall speed.
</p>
<blockquote>
Sometimes we use exceptions to manage the flow of our scripts. I imagine that the use of exceptions must have a performance lack. Because of that I will perform a small benchmark to test the performance of one simple script throwing exceptions and without them.
</blockquote>
<p>
His (little) benchmarking scripts are included - both looping 100000 times, one throwing an exception and the other not. The results were pretty obvious - the memory usage was about the same but the speed was about ten times faster without the exceptions (in PHP 5.3). In PHP 5.4, however, the numbers were closer as far as time to run. Obviously, unless you make super heavy use of exceptions, you're not even going to come close to something like this (micro-optimization anyone?).
</p>]]></description>
      <pubDate>Tue, 17 Jan 2012 08:02:24 -0600</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[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[Fabian Schmengler's Blog: "Mocking" built-in functions like time() in Unit ]]></title>
      <guid>http://www.phpdeveloper.org/news/16065</guid>
      <link>http://www.phpdeveloper.org/news/16065</link>
      <description><![CDATA[<p>
In a recent post to his blog <i>Fabian Schmengler</i> looks at mocking something in your unit tests that could cause problems in certain situations - needing a specific kind of response from a built-in PHP function. In his case, he <a href="http://www.schmengler-se.de/-php-mocking-built-in-functions-like-time-in-unit-tests">shows how to mock</a> <a href="http://php.net/time">time</a> to return the same formatted date.
</p>
<blockquote>
A common problem in Unit Testing in PHP is testing something that depends on the current time. For a determined test it should be possible to set the time in your test script without really changing the system settings. In this article I'll describe how it is usually done with OOP and then come to an alternative solution with much less code that makes use of the new features in PHP 5.3.
</blockquote>
<p>
He shows a usual approach using dependency injection and a class wrapper to handle the set and fetch of the date value. His alternative uses namespacing to redefine the internal PHP function into something custom. Then, when the test is executed, it can use that custom namespace's version, overriding the default. It's a pretty seamless option and can save you a good bit of time and hassle with other classes each time you need to customize the results.
</p>]]></description>
      <pubDate>Fri, 18 Mar 2011 08:52:03 -0500</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[Till Klampaeckel's Blog: APC: get a key's expiration time]]></title>
      <guid>http://www.phpdeveloper.org/news/15417</guid>
      <link>http://www.phpdeveloper.org/news/15417</link>
      <description><![CDATA[<p>
<i>Till Klampaeckel</i> has shown off one of the "best kept secrets" about the APC caching tool that not many people seem to use - <a href="http://till.klampaeckel.de/blog/archives/124-APC-get-a-keys-expiration-time.html">getting a key's expiration time</a> that can be useful to tell other applications how long the data will be good for.
</p>
<blockquote>
APC offers a bunch of very useful features - foremost a realpath cache and an opcode cache. However, my favorite is neither: it's being able to cache data in shared memory. How so? Simple: use apc_store() and apc_fetch() to persist data between requests. The other day, I wanted use a key's expiration date to send the appropriate headers (Expires and Last-Modified) to the client, but it didn't seem like APC supports this out of the box yet.
</blockquote>
<p>
He includes a quick bit of sample code that defines an "apc_exire" function that grabs the expiration information as returned by apc_cache_info - the "ttl" and "creation_time" values.
</p>]]></description>
      <pubDate>Thu, 11 Nov 2010 11:28:55 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Brandon Savage's Blog: The Fallacy of Sunk Cost]]></title>
      <guid>http://www.phpdeveloper.org/news/14494</guid>
      <link>http://www.phpdeveloper.org/news/14494</link>
      <description><![CDATA[<p>
<i>Brandon Savage</i> has a new post about something that some developers out there factor into their development estimates from the beginning and others are just learning how to adjust to - the <a href="http://www.brandonsavage.net/the-fallacy-of-sunk-cost/">sunk cost</a> that can be associated with writing code.
</p>
<blockquote>
Last week, I began working on something that didn't pan out. For whatever reason, I went down the wrong path, and ultimately abandoned the task I was working on. In discussing it with my boss, he mentioned to me that it was better to realize early on that something wouldn't work than to trudge onward, insisting that it be finished due to the "sunk cost" of the time already spent.
</blockquote>
<p>
There's two sides to this story - one in which the application continues to be developed and takes up more time (but still ends up as a product) and the other where the time already spent is lost as a completely new approach is taken.
</p>]]></description>
      <pubDate>Tue, 11 May 2010 09:35:28 -0500</pubDate>
    </item>
  </channel>
</rss>
