DateTime: My new best friend
This post is more than 18 months old. Technology changes quickly, so some of this content may be out of date (but that's not always the case). Please verify any technical or programming information against the current release.
I have a new love affair… PHP’s DateTime object. I’m not sure when it started, but it’s going on strong now. If you haven’t taken a look at it, I invite you to run over there now and just look at the methods. If that isn’t enough, let me give you a bit of example code… see if this makes you really want to do it:
$firstDate = new DateTime('01/12/2012 10:00:00');
$secondDate = new DateTime('2012-01-01 23:23:23');
echo $firstDate > $secondDate ? "First Date is Newer" : "Second date is newer";php
What do you think the output will be? How EASY is that?!