can any one pls help on the below thing

I am having a value as


But I required the above data should be converted as time as below


Likewise it should be viceversa

cast as int to remove value after "."

then parse

Try this

function setMyValue ($myValue) {
$newValue = (int)$myValue;
$myArray = array_reverse(str_split($newValue));
$myValue ="";
foreach ($myArray as $key=>$myDigits) {
    $myValue.=($key>0 && $key%2==0) ? ":" : "";
    $myValue.= $myDigits;
return strrev($myValue);

echo setMyValue(91819.0);

Hi Bachov

Thanks for your code

Member Avatar

Casting as int will not round the float to an integer. Well, actually I suppose it rounds down like ceil(). It simply truncates.

If you want the decimal part to be considered, then I suggest you use the round() function to get your integer.


$time = strrev(implode(":", str_split(strrev(round($myValue)), 2)));


Hi Bachov Varghese

Thanks.is working fine.