Clean break.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux