Page 1 of 1

about date

Posted: Thu Apr 22, 2004 3:48 am
by bugthefixer
my prog compare two times input by user in a format 00:00:00 and its 24 hrs format...right now it only check whether 20:00:00 is before 21:00:00 but now i want to make it such a way that it can also tell me that 20:00:00 of first day is before 19:00:00 of second day...my present code is

Code: Select all

<?phpfunction compareTime($str) {
	$day=1;
	$arr=split(":",$str);
	global $time;
	if(isset($time))
		{
		$prev_time=$time;
		$time=mktime($arr[0],$arr[1],$arr[2],1,$day);
		if($time<$prev_time)
			return 1;
		}
	else {
		$time=mktime($arr[0],$arr[1],$arr[2],1,$day);
		return 1;
		}	
	}


?>
in other words i need some way to increment $day so that it can handle days as well..

Posted: Thu Apr 22, 2004 7:07 am
by kettle_drum
You could use your time values in mktime() which will return the number of seconds in the date so you can easily compair them.