PHP display based on date range

4 posts by 3 authors in: Forums > CMS Builder
Last Post: June 23, 2009   (RSS)

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.
Cheers,
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.

<?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

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.