Clean break.
| From: | Paul Halliday | Date: | Fri, 31 Jul 2009 21:22:21 +0000 |
| Subject: | Clean break. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-296146@lists.php.net to get a copy of this message | ||
Whats the cleanest (I have a really ugly) way to break this:
[21/Jul/2009:00:00:47 -0300]
into:
date=21/jul/2009
time=00:00:47
Caveats:
1) if the day is < 10 the beginning of the string will look like "[<space>1/...
2) the "-0300" will differ depending on DST or TZ. I don't need it
though, it just happens to be there.
This is what I have (it works unless day < 10):
$theParts = split("[\"]", $theCLF);
// IP and date/time
$tmpParts = explode(" ", $theParts[0]);
$theIP = $tmpParts[0];
$x = explode(":", $tmpParts[3]);
$theDate = str_replace("[","", $x[0]);
$theTime = "$x[1]:$x[2]:$x[3]";
the full text for this part looks like:
10.0.0.1 - - [21/Jul/2009:00:00:47 -0300] ... more stuff here
Anyway, any help would be appreciated.
thanks.