Skip to content

Commit

Permalink
Removed microseconds from long form date strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mike27cubes committed Dec 14, 2017
1 parent 2fed8c1 commit 78a19ca
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions inc/classes/LogParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 : <code>$str</code>";
Expand Down

0 comments on commit 78a19ca

Please sign in to comment.