Jump to content

Help: Echo div on specific date


gjunkie

Recommended Posts

So I've got this function going in wordpress:

 

function new_post_badge(){

if ( (time()-get_the_time('U')) < (1*86400) ) { // The number 1 is the number of days

echo '<div class="todaysevent"></div>';

}

}

 

It works a little weird. The 86400 is the seconds. Basically what I want it to do is echo a div class if the post date/time of a blog post is less than 24hrs.

 

What this is doing tho is echoing the div for every post dated past the current date... its an events site, so posts are dated in the future. All posts dated older than the current date don't echo it. I'm obviously doing something wrong.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/183041-help-echo-div-on-specific-date/
Share on other sites

the day you compare to needs to be static and you need to pull the post information from a database which will hold a time stamp of when it was posted and then compare the timestamp to the day that you need to compare to, in this case, the current day.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.