Jump to content

[SOLVED] If time is older than 1 minute.


lynxus

Recommended Posts

OK that works ( ithink. )

This is what im attempting, but doesnt seem to work.

 

im doing a select blaa,blaaa,CURRENT_DATE from blaaa;

 

$time = $row['lastseen'];
$cdate = $row['current_date'];

echo $cdate;

if (strtotime($time)-30 > $cdate) {
echo '<td><img src="Images/useronline.png" border="0" /></td>';
}else{
echo '<td><img src="Images/useroffline.png" border="0" /></td>';
}

 

What am i doing wrong?

 

time() contains the current time (obviously). Just compare the lastseen with the current time. The lastseen has to be converted to a UNIX timestamp which is what strtotime does.

 

if (strtotime($time)-30*60 > time()) {
echo '<td><img src="Images/useronline.png" border="0" /></td>';
}else{
echo '<td><img src="Images/useroffline.png" border="0" /></td>';
}

should do it (assuming you mean 30 minutes and not 30 seconds).

Humm using.

 

if (strtotime($time)-30 > time()) {
echo '<td><img src="Images/useronline.png" border="0" /></td>';
}else{
echo '<td><img src="Images/useroffline.png" border="0" /></td>';
}

 

doesnt work.

it still shows the offline image.

 

The timestamp is being updated in the db, and it is in the var as i can echo it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.