note 38658 added to function.strtotime

From: Date: Thu, 01 Jan 2004 20:24:21 +0000
Subject: note 38658 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-62758@lists.php.net to get a copy of this message
I was having trouble parsing Apache log files that consisted of a time entry (denoted by %t for Apache configuration). An example Apache-date looks like: [21/Dec/2003:00:52:39 -0500] Apache claims this to be a 'standard english format' time. strtotime() feels otherwise. I came up with this function to assist in parsing this peculiar format. <?php function from_apachedate($date) { list($d, $M, $y, $h, $m, $s, $z) = sscanf($date, "[%2d/%3s/%4d:%2d:%2d:%2d %5s]"); return strtotime("$d $M $y $h:$m:$s $z"); } ?> Hope it helps anyone else seeking such a conversion. ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38658 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38658&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38658&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#62758) next »