Page 1 of 1

date time query

Posted: Wed Nov 24, 2010 8:34 am
by IGGt
I'm picking up a datetime from a database and need to check whether it is greater than 30 minutes old.

e.g.

$date = 2010-11-24 14:12:55

If $date < (now - 30 minutes) then do this
else
do this

but I'm struggling to see how to do this, I can only find examples of static dates e.g. day1 - day2.

I'm sure this must be relatively straight forward.

Re: date time query

Posted: Wed Nov 24, 2010 11:22 am
by IGGt
found a way to do it:

Code: Select all

	$half = time()-1800;
	$quart = time()-900;
	$con = strtotime($Aresult['ConnectedAt']);
	
	IF ($con < $half) {
		$col = $colour1;
	}elseif ($con < $quart) {
		$col = $colour3 ;
	}else{
		$col = $colour2;
	};