php string convert

I need to convert a string from 170652 to 17:06:52
glyncoAsked:
Who is Participating?
 
Kiran SonawaneConnect With a Mentor Project LeadCommented:
Try like this

$time = "170652";

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

echo $new_time
0
 
shobinsunCommented:
$value2 = "170652";
$words2 = str_split($value2, 2);
print_r($words2[0].':'.$words2[1].':'.$words2[2]);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.