php string convert

glynco
glynco used Ask the Experts™
on
I need to convert a string from 170652 to 17:06:52
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Project Lead
Top Expert 2011
Commented:
Try like this

$time = "170652";

$new_time = implode(':', str_split($time, 2));

echo $new_time
$value2 = "170652";
$words2 = str_split($value2, 2);
print_r($words2[0].':'.$words2[1].':'.$words2[2]);

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial