CodeSOD: The Myth of Datyphus

This post was originally published on this site

The Daily WTF

PHP gets a lot of flack, but perhaps we’re taking the wrong perspective on things. Perhaps the gods have condemned PHP to ceaselessly rolling CMSes and wikis up the hill, whence they roll back down under their own weight. The gods had thought, with some reason, that there is no more dreadful punishment than futile and hopeless labor.

I mean, look at this code:

$migrateStartTime = date(“Y-m-d”, strtotime(date(‘Y-m-d’, time()))); // Four other lines of code $startDateTime = DateTime::createFromFormat(‘Y-m-d’, date(‘Y-m-d’)); $startDateTimeIdentifier = $startDateTime->format(‘Y-m-d’);

Is there anything more futile than that first line? Get the current time, format it as a date, convert the formatted string back into a date, and then convert that date into a string with the same format.

I leave PHP at the foot of its codebase. One always finds one’s burden again. But PHP teaches the higher fidelity that negates the gods and raises date

To read the full article click on the 'post' link at the top.