Mistři v programování na #hovnokod

PHP #110

// get today's date string as YYYY-MM-DD HH:MM:SS

   function getDateTime(){
       $datetime = getdate();
       $mday = $datetime['mday'];
       if ($mday<10){
           $mday="0$mday";
       }
       $mon = $datetime['mon'];
       if ($mon<10){
           $mon="0$mon";
       }
       $year = $datetime['year'];
       $mhour = $datetime['hours'];
       if ($mhour<10){
           $mhour="0$mhour";
       }
       $mmin = $datetime['minutes'];
       if ($mmin<10){
           $mmin="0$mmin";
       }
       $msec = $datetime['seconds'];
       if ($msec<10){
           $msec="0$msec";
       }

       $dateTime = "$year-$mon-$mday $mhour:$mmin:$msec";
       return $dateTime;
   }

Anonymous,