• Can anyone help me to sort out the following code. I would like posts from today to be datestamped “today”,. and previous posts to take a date stamp. I wrote the following code which of course doesn’t work.

    <?php
    $today = date("dmy");
    $published = the_time("dmy");
    if($today == $published){?>Today <?}else{?> <?the_time("l")?>, the <?the_time("j")?><?the_time("S")?> of <?the_time("F")?>
    <?}?>

    I am going ka ka koo koo. If WP’s loop has a variable with just a clean date stamp I think I would use that…but it returns a date and a time, and I don’t know how to just strip out the date from that.
    Can anyone come with a solution? I know the root of my problem comes from trying to embed WP functions in my own PHP code.
    I also think it would be nice to have the ability to use relative date/time stamp posts in the same way that textpattern does (for ex. “posted 2 hours ago”, “posted 4 days ago”, etc) Maybe there are some plug-ins which I just haven’t located yet.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress Date function woe’ is closed to new replies.