News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Gonzalo Ayuso:
Handling dates with PHP
October 02, 2012 @ 08:41:09

In this new post to his site Gonzalo Ayuso introduces you to one of the more powerful parts of the PHP language - the DateTime object.

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″ and I ask him: What is it? If your answer is "This is a date" you should continue reading the post.

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 date 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.

This is just the tip of the iceberg as to what DateTime can do, so I'd suggest checking out the manual page for it to see the full list of features.

0 comments voice your opinion now!
datetime date time handling introduction formatting


blog comments powered by Disqus

Similar Posts

ZendCasts.com: Fun with Phar

Lorna Mitchell: How NOT to Design Your API

SitePoint PHP Blog: HHVM and Hack - Can We Expect Them to Replace PHP?

SitePoint.com: The CakePHP Framework: Your First Bite

Inside Open Source: Two New Articles (Date/Time & Services_Google)


Community Events

Don't see your event here?
Let us know!


performance configure laravel example part2 php7 community symfony2 application api framework introduction conference interview opinion series voicesoftheelephpant release language podcast

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework