No worries, Ive done a nasty hack that seems to work fine!
PHP Code:
# Format = Sat Dec 11 11:15:19 2010 # New format = 2010-12-31 10:08:00
$line = "Sat Dec 11 11:15:19 2010 SOME OTHER ****TY DATA NOT NEEDED"; // Change date format $time = substr($line, 0, 24); // Get date. $chunks = preg_split('/\s+/', $time);
$month = $chunks[1]; switch ($month){ case "Jan": $month = "01"; break; case "Feb": $month = "02"; break; case "Mar": $month = "03"; break; case "Apr": $month = "04"; break; case "May": $month = "05"; break; case "Jun": $month = "06"; break; case "Jul": $month = "07"; break; case "Aug": $month = "08"; break; case "Sep": $month = "09"; break; case "Oct": $month = "10"; break; case "Nov": $month = "11"; break; case "Dec": $month = "12"; break; } $time = "$chunks[4]-$month-$chunks[2] $chunks[3]";
// Now echos $time as 2010-12-22 17:06:51 for example :) YAY
Last edited by lynxus; 12-31-2010 at 05:24 AM..
|