On Friday 19 Sep 2003 10:20, David T-G wrote:
> Hi, all --
>
> Now it's my turn to ask a simple question, or one that sure sounds like
> it should be...
>
> I have a 14-char date string like "20030917181909" and I need to break it
> into its component parts for a more readable "2003-09-17 18:19:09" view.
> How can I do that?  Do I really need to call substr half a dozen

In perl I'd do something like:
$time =~ m/(\d){4}(\d){2}(\d){2}(\d){2}(\d){2}(\d){2}/;
$ntime = "$1-$2-$3 $4:$5:$6";

I think php can do that with preg_match, using an array to hold the matches.

As the other poster said, if this is mysql, let mysql do the work for you :)

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

Reply via email to