So I have a php function which interacts with a database and pulls data out. However I have a date stamp (in this case an upload date). I want to make it so that if something has been uploaded within the last 7 days, it posts that to users to make them aware of it being 'new'.
So far I have this:
if( strtotime($rows['Date']) > strtotime('now') ) { echo '<div class="l-new"><a href="#"><!-- --></a></div>'; }
The $rows thing is taken care of and works from some other code above this line. But this is the line I am concerned with.
I want to say "if the date in the database is older than the current time, and is less than 7 days old, do the following { //echo the stuff about it being new }
Problem is, how do I phrase that if statement to make it within 7 days? Absolutely cannot think of how unfortunately. I'm sure it is quite simple! Thank you
if( strtotime($rows['Date']) > strtotime('-7 day') ) { echo '<div class="l-new"><a href="#"><!-- --></a></div>'; }
The strtotime('-7 day')
part returns the time 7 days ago.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With