Hi all,

I am working on a script that converts Hexedecimal time to human readable time.

For some reason the only part I can't get to work is inserting a leading zero (0) as and when required. The code below works on a hexedecimal time of "03C5" which when converted reads "165" but I need to place a zero in front of the "5" so it reads "1605".

Any anyone see where I am going wrong.

$SchTimeT = "03C5";
	$SchDec = hexdec($SchTimeT);
	$SchHoursNumVal = $SchDec /60; 
	$SchHrs = floor($SchDec/60); 

if(strlen($SchHrs < "2")){
	$SchHours = "0".$SchHrs;
} else {
	$SchHours = $SchHrs;
}

$SchDecHrs = $SchHoursNumVal - $SchHrs;
$SchMinVal = $SchDecHrs * 60;
$SchMins = round($SchMinVal,0);

if(strlen($SchMins < 2)){
	$SchMinutes = "0".$SchMins;
} else {
	$SchMinutes  = $SchMins;
}
$SchTime = $SchHours."".$SchMinutes;

    Hi all,

    Sorry for the post, I have resolved it.

      Write a Reply...