• I’d post on the plugin support page, but it says that it is no longer supported, so I thought I’d ask here.

    So first, I was using the php code as provided by the default theme:

    <$ php $entry_datetime = abs(strtotime($post->post_date)
     - (60*120)); echo time_since($entry_datetime); echo '
     ago'; ?>

    And that worked fine except for on entries that are posted on the day of. I made a test entry today and it said something like ‘This entry was posted -1 year, 256 days ago,’ which is a roundabout way of saying today, I guess.

    So, I went to the plugin site and copy and pasted the code from there:
    `
    <?php if (function_exists(‘time_since’)) {
    echo time_since(abs(strtotime($post->post_date_gmt . “ GMT”)), time()) . “ ago”;
    } else {
    the_time(‘F jS, Y’);
    } ?>’

    And that gives me this error:

    Parse error: parse error, unexpected T_STRING in /index.php on line 12

    which I know has something to do with not putting in backslashes where there’s a single quote or something of that sort, but I can’t see the error (probably due to inexperience).

    I need help on one of two things: make the first code work better. I’d like a post that I post today to say “this was posted x hours, x minutes ago.” It works now, just not the way I’d like it to.

    Or. Find the error in the second code so that I can see if that one works any better.

    Please and thank you! I’d really appreciate any help on this.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    <?php if (function_exists('time_since')) { echo time_since(abs(strtotime($post->post_date))).' ago'; } else { the_time('F jS, Y'); } ?>

    Try that.

    Failing that, I dunno. I’d have to try it myself and see what happens.

    Thread Starter aramise

    (@aramise)

    Hmm.. I tried that and it gives me the same results (posted -1 year ago) as before. Thanks for the help though.

    May I ask what makes it different than either of the original coding?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    I was just attempting to fix your second bit of code to not give the error, I have no idea what “time_since” actually does.

    Thread Starter aramise

    (@aramise)

    time_since is the plugin I’m using. It displays the time since a post was created in terms of years to seconds. So if I posted 2 hours ago, the plugin would tell the reader so, rather than just showing a simple time stamp.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Yes, I guessed that. I mean I don’t know what the code does. If it’s giving you negative amounts, then it’s some kind of problem in the plugin. Since I don’t have the plugin (site is blocked at my workplace), I’m not the best person to ask about it. ??

    Try

    Posted <?php
    if(function_exists('time_since')) {
    	$entry_datetime = abs(strtotime($post->post_date));
    	echo time_since($entry_datetime, time());
    	echo ' ago ';
    } ?>
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Dunstan’s Time Since’ is closed to new replies.