All pastes #415491 Raw Edit

Something

public text v1 · immutable
#415491 ·published 2007-03-29 17:50 UTC
rendered paste body
function transTime($time)//function to convert the time

{

	$colSlot = strpos($time, ':');//find out where the colon is placed

	$h = substr($time, 0, $colSlot);//read the hour part of the time

	$m = substr($time, $colSlot + 1, 2);//read the minute part of the time

	$meridum = substr($time, $colSlot + 4, 2);//read the AM/PM part of the time

	if($meridum == 'PM')//if PM, add 12 hours to the $h

	{

		$h = 12 +$h;	

	}	

	$time = $h. ':'. $m;

	return $time;//return the converted time

}

//this function is feeded with 12h format time in the following format hh:mm and after that AM/PM