PHP display based on date range
4 posts by 3 authors in: Forums > CMS Builder
Last Post: June 23, 2009 (RSS)
By ncasares - June 22, 2009
I'm trying to figure out how to display an image based on the 'updatedDate' of a record. I'd like to show the image if a record has been updated within the past 30 days. I'm sure this is simple, but I'm struggling with the function for comparing the 'updatedDate' to a day 30 days ago.
I don't want to limit the query based on date, just the display of a "new" image.
Can anyone help point me in the right direction?
Thanks!
I don't want to limit the query based on date, just the display of a "new" image.
Can anyone help point me in the right direction?
Thanks!
Re: [ncasares] PHP display based on date range
By Damon - June 22, 2009
Thanks for sending the additional details via email and chatting on the phone.
I will put together a quote for you for this and the other requirements and get back to you shortly.
I will put together a quote for you for this and the other requirements and get back to you shortly.
Cheers,
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [ncasares] PHP display based on date range
By Dave - June 23, 2009
Hi ncasares,
I understand there's more to this project that Damon is quoting for you, but here's some code for the date part you asked about. It will set a variable with how many "days old" a record is based on it's date and then test that to display new for the first 30 days.
Hope that helps!
I understand there's more to this project that Damon is quoting for you, but here's some code for the date part you asked about. It will set a variable with how many "days old" a record is based on it's date and then test that to display new for the first 30 days.
<?php
$secondsOld = time() - strtotime($record['date']);
$daysOld = intval($secondsOld/60/60/24);
?>
Days old: <?php echo $daysOld ?><br/>
<?php if ($daysOld <= 30): ?> NEW! <?php endif ?>
Hope that helps!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com
Re: [Dave] PHP display based on date range
By ncasares - June 23, 2009
Hi Dave,
Thanks for the info. I've gone ahead with a consulting project on this one, but I'm sure the info is useful to the community. Thanks.
Thanks for the info. I've gone ahead with a consulting project on this one, but I'm sure the info is useful to the community. Thanks.