please see the function/code below

function mg_time($param1, $param2='', $mode='minsec'){
	/*
	2007-05-14 this will eventually be a "class" to work with time in all formats
	*/
	echo $param1;
	switch(true){
		case $mode=='minsec':
			/*
			0-60 = seconds
			61- 59min = n minutes and n seconds
			1 hour and 13 seconds
			1 hour, 1 minute and 13 seconds
			2 hours and 13 seconds
			..
			1 day
			*/
			$x=$param1;
			$sec=$t[0]=$x%60;
			if($x>60-1){
				$min=$t[1]= (($x-$sec)/60)%60;
			}
			if($x>3600-1){
				$hours=$t[2]= (((($x-($min*60)-$sec)/3600))+20)%24; //add 20 hours
			}
			if($x>(3600*24)-1){
				$days=$t[3]= (($x-($hours*3600)-($min*60)-$sec)/(3600*24))%(3600*24);
			}
			echo '<pre>';
			print_r($t);
		break;

}

}
mg_time(strtotime($n));

the problem is when $n is: 1971-04-25 23:59:59
hours comes out as 23 (t[2])
but when $n is: 1971-04-24 23:59:59
hours comes out as 0

all dates after 4/25/71 the hours are "correct" and all dates before 4/24/71 the hours are "incorrect" - any idea what might be happening here? 1971 must have been an unusual year..

Thanks,
Samuel

    Write a Reply...