...

View Full Version : Time Since Entry



GSimpson
08-21-2007, 08:14 AM
Heya,

I was on bebo earlier, and saw the comments say "1 Hour Ago", I was wondering if I had a mysql row that had a timestamp under the name "date", how could I have it so that if timestamp less than thirty days old, it would echo <img src="images/layout/new.gif" alt="New Product!"/> but if it was older than 30 days, it wouldn't echo anything.

I have thought about it and there must be specific functions, that compare that timestamp to the timestamp of now, it seems like something php wud have.

westmatrix99
08-21-2007, 02:44 PM
An if statement could fix that.

if comment_date => 30 days { //not sure about the => or <= or ==
<img src="images/layout/new.gif" alt="New Product!"/>
}
else
{
echo "Older than 30 days"
}

Inigoesdr
08-21-2007, 03:04 PM
$then = time() - (60 * 60 * 24 * 30);
if($date < $then)
{
// more than 30 days ago
}
else
{
// less than 30 days ago
}
There are probably hundreds of ways of doing this.

Date and Time Functions (http://www.php.net/manual/en/ref.datetime.php)

westmatrix99
08-21-2007, 03:06 PM
That was quick, and I think that should work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum