By Adam O. on Tuesday, 29 December 2015
Replies 1
Likes 0
Views 1K
Votes 0
Hi there,

I've got a question about categories.

I need to check in list of posts, if post is added (published) not later than eg. 3 hours.

For example:

if post publish date < 3 hours {

echo 'This post is new!';
}

and

if post publish date < 24 hours {
echo 'This post is published in last 24 hours!';
}

else { don't show nothing}

So how can I check this and show in post in list view (default.main.php) by adding some short code?

I'll be very grateful for your help with this thread!
Best regards!
Adam
Hello Adam,

I can't provide you full code to do this. However, I can give you some of it for you to start the customization:


$interval = (strtotime(date("Y-m-d H:i:s")) - strtotime($post->publish_up)) / 60; // this will return interval in minutes.

if ($interval <= 180) {
// less than 3 hours. 180 minutes.
}



You need to use this code in the default.main.php.

Hope this helps.
·
Tuesday, 29 December 2015 16:21
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post