Dates in PHP

I’ve always been impressed by PHP, and today was no exception when I encountered PHPs date handling for the first time.

Part of what makes the system so elegant is that it doesn’t really have a date type. Well, there is a type as of PHP 5.2, but as far as I can make out, it simply extends timestamp. And that’s just fine, for my purposes at least.

So, in this case, I need to get a string datestamp for an output in XML. And it should be configurable for any day next week. But in PHP there’s no need to go though all the while( !todayIsSaturday) { day+1} nonsense to get it… it’s really simple

$sat = strtotime("next Saturday");

Despite my dreaming, I can’t see this being a feature in Java 7’s new Calendar format… Java dates wouldn’t be the same if they weren’t so damn awkward 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s