Solved

php string convert

Posted on 2012-04-03
2
226 Views
Last Modified: 2012-04-03
I need to convert a string from 170652 to 17:06:52
0
Comment
Question by:glynco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 500 total points
ID: 37800272
Try like this

$time = "170652";

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

echo $new_time
0
 
LVL 14

Expert Comment

by:shobinsun
ID: 37800324
$value2 = "170652";
$words2 = str_split($value2, 2);
print_r($words2[0].':'.$words2[1].':'.$words2[2]);
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question