PHP Checking if timestamp is less than 30 minutes old

Viewed 43153

I'm getting a list of items from my database, each has a CURRENT_TIMESTAMP which i have changed into 'x minutes ago' with the help of timeago. So that's working fine. But the problem is i also want a "NEW" banner on items which are less than 30 minutes old. How can i take the generated timestamp (for example: 2012-07-18 21:11:12) and say if it's less than 30 minutes from the current time, then echo the "NEW" banner on that item.

3 Answers

You can do like this also -

$currentTime=time(); 

to check the last updated time is 30 minute old or not

last_updated_at <  $currentTime - (60*30)
Related