Jump to content

"New posts"


oz11
Go to solution Solved by Barand,

Recommended Posts

I wrote this..

                    $now = strtotime('now');
                    $now = date('Y-m-d', $now);
                    $day = date('Y-m-d', strtotime($row['date'] . ' + 2 weeks'));

                    if($day < $now){
                        echo "<img src='https://i.imgur.com/0rlIlUD.gif'>";
                    }
                    

It should show a "new" gif image on new posts.. however, they only show on posts that are not new. I tried flipping the "<" to ">" but doesn't work.... not sure what to do. So simple but get can't grasp the conditional .

Help Internet freaks.

Edited by oz11
Link to comment
Share on other sites

Still not fixed it . You would think flipping it would work as it sorta did before, but opposite. all t he ones that shouldn't be "new" were new and all the other actual "new" posts were not showing.. weird. Never come across anything like it.

Edited by oz11
Link to comment
Share on other sites

12 minutes ago, Barand said:

This works for me  (if I substitute a datetime value over 2 weeks old for $row['date'] )

$day = date('Y-m-d', strtotime("2023-08-28 16:03:32" . ' + 2 weeks'));

if ($day < date('Y-m-d'))  {
    echo "img src='https://i.imgur.com/0rlIlUD.gif'";
}

 

Still shows on the reverse but not the other way round hmm. (showing on all the old ones but not the new ones)

Edited by oz11
Link to comment
Share on other sites

  • Solution
59 minutes ago, oz11 said:

It should show a "new" gif image on new posts

Do I take it that a new image is one that is less than 2 weeks old?

$day = date('Y-m-d', strtotime("2023-08-30 16:03:32"));

if($day > date('Y-m-d', strtotime('-2 weeks'))){
    echo "img src='https://i.imgur.com/0rlIlUD.gif'";
}

@requinix - I see what you mean :facepalm:

  • Like 1
Link to comment
Share on other sites

Ended up doing this which worked...

 

//$day = date('Y-m-d', $row['date']);
$day = date('Y-m-d', strtotime($row['date']));

if($day < date('Y-m-d', strtotime('-2 weeks'))){
} ELSE {
        echo "<img src='ttps://i.imgur.com/0rlIlUD.gif'>";

}

abit of a workaround but ok for me. Thanks guys!

Edited by oz11
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.