"I don't consider myself to be a programmer," Michael H writes, "but I have written my share of Perl and PHP. It's not that I dislike coding, it's just that I've moved to the sys admin side of things, and it's probably better for everyone that my kind doesn't write code.

"However," Michael continues, "because our IT department is so small (just myself and a programmer), my job responsibilities do include fixing hyper-critical-emergency bugs should they arise when the programmer is unavaiable. The same holds true if hyper-critical-emergency server issues arise when I'm unavailable: the programmer will jump in and do what he can."

"For years, we’ve never needed to put on each other's hats. Recently, however, the programmer was away on vacation and something big happened in one of our PHP applications. I had a good idea of how to fix it, so I dove into the appropriate .php file. And that's when I saw this date formatting code."

<?php
   #get date
   $now=getdate();

   #break it out into globals
   $hour=$now['hours'];
   $minute=$now['minutes'];
   $second=$now['seconds'];
   $month=$now['mon'];
   $day=$now['mday'];
   $year=$now['year'];

   #format the globals
   $hour=str_pad($hour, 2, "0", STR_PAD_LEFT);
   $minute=str_pad($minute, 2, "0", STR_PAD_LEFT);
   $second=str_pad($second, 2, "0", STR_PAD_LEFT);
   $month=str_pad($month, 2, "0", STR_PAD_LEFT);
   $day=str_pad($day, 2, "0", STR_PAD_LEFT);
   $year=str_pad($year, 4, "0", STR_PAD_LEFT);

   #BUILD USEFUL STRINGS
   $serverdate=$year . "-" . $month . "-" . $day;
   $servertime=$hour . ":" . $minute . ":" . $second;

   #BUILD STRINGS FOR WEBPAGES
   $htmlserverdate=$serverdate;
   $htmlservertime=$servertime;
   $htmltime=$hour . ":" . $minute;

?>

"For those who are unfamiliar with PHP (which, apparently, includes my coworker, the PHP programmer), there is a one-line replacement for this mess called date(). If this is the work that he does when he wears the programmer hat, I'm going to make sure that I'm always available, so he never can put on the system administrator hat."

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!