From 78a19cada32c77c7731c638d1a92aacb8424d7ae Mon Sep 17 00:00:00 2001 From: Mike Hickey Date: Thu, 14 Dec 2017 10:33:23 -0500 Subject: [PATCH] Removed microseconds from long form date strings Issue https://github.com/potsky/PimpMyLog/issues/133 --- inc/classes/LogParser.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/inc/classes/LogParser.php b/inc/classes/LogParser.php index 5a43ff48..e996af22 100644 --- a/inc/classes/LogParser.php +++ b/inc/classes/LogParser.php @@ -465,6 +465,13 @@ public static function parseLine( $regex , $match , $log , $types , $tz = null ) $dateformat = substr( $dateformat , 0 , $p ); } + $matches = array(); + if ( ( preg_match( '/([A-Z]{3}) ([A-Z]{3}) ([0-9]{1,2}) ([0-9]{2}:[0-9]{2}:[0-9]{2})\.[0-9]+ ([0-9]{2,4})/i', $str, $matches ) ) ) + { + // Remove microseconds from datetime string + $str = $matches[1] . ' ' . $matches[2] . ' ' . $matches[3] . ' ' . $matches[4] . ' ' . $matches[5]; + } + if ( ( $timestamp = strtotime( $str ) ) === false ) { $formatted_date = "ERROR ! Unable to convert this string to date : $str";