On Jul 31, 2009, at 5:22 PM, Paul Halliday <paul.halli...@gmail.com> wrote:

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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Since it's a fixed length value, what about just using substr() to pull out the various bits?

Bastien

Sent from my iPod

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to