• karlb

    (@karlb)


    Hi there,
    I wondered if you or someone else who has a date since got codegurls script up and running in WP.
    This is the code: https://typicalgeek.net/code/php/wp/the_date_since.phps
    Did you add this to my-hacks.php? or was it implemented another way.
    I am not really sure how you actually call this so of someone could assist that would be great ??
    Thanks
    Karl

Viewing 15 replies - 1 through 15 (of 15 total)
  • kashirow

    (@kashirow)

    You can just add this to my-hacks.php and call it within the loop in index.php, it will work.

    Thread Starter karlb

    (@karlb)

    Hi there,
    How would I actually call it please? Sorry I am only just undestanding PHP ??
    Thanks
    Karl

    Chris J. Davis

    (@chrisjdavis)

    After you paste the code into your my-hacks.php file insert this code snippet where you want the date_since info to appear:

    <?php the_date_since() ?>

    That is it, you should now be rockin and rollin.
    Hope this helps.
    Chris

    kashirow

    (@kashirow)

    Don’t forget the ‘;’ – statements have to be terminated with semicolon in PHP, so it should really be:
    <?php the_date_since(); ?>

    Thread Starter karlb

    (@karlb)

    Hey Guys,
    Thanks for that ??
    Karl

    tcervo

    (@tcervo)

    Yeah, what Jesuit and KAShirow said…
    -Tony

    tcervo

    (@tcervo)

    Karl,
    Yes, that would remove hours, minutes, and seconds. I would recommend keeping hours, though…otherwise, anything less than 24 hours old won’t display anything. For example, on my blog I have the_date_since incorporated so it outputs like this:
    “Posted 3 days 18 hours 5 minutes ago in the Pop Culture category.”
    Getting rid of hours, and minutes (I’ve already got rid of seconds) would output the following for those that are less that 24 hours old:
    “Posted ago in the Pop Culture category.”
    So, if you’re going to get rid of days, make sure it still makes sense when no days are displayed.
    -Tony

    kashirow

    (@kashirow)

    This one’s not quite as easy. (took me a while to figure out since I kept trying to use the_date instead of the_time… meh…) Put it into my-hacks.php. Then call it like this:
    <?php echo time_since(the_time(‘U’,”,”,false)); ?>
    This will give the output you want for a specific posting, feeding this formatting function the epoch time of the post, which it wants.

    kashirow

    (@kashirow)

    Hmmm… Not sure why this happens, it gave me sane answers when I tried it. (like 1 day 7 hours, etc.)

    1. Are you sure your server time is correct and your time difference in WordPress configuration is set up properly?
    2. Are you sure it did not change between postings?
    3. Are you using WP 1.01, or a recent CVS? They changed a lot of things regarding storing time in GMT in CVS, so this might be due to that.
    Thread Starter karlb

    (@karlb)

    Ah now my server is in the USA and I am in the U.K. which is +6 hours on the server time.
    My WP is set up correctly for this but I don’t know what to do to get a +6 on the date_since PHP script.
    Any ideas?
    Thanks
    Karl

    Thread Starter karlb

    (@karlb)

    I have an update to this.
    Someone has told me to add this (below) to just add the extra difference to the string. What does he actually mean when he tells me this?
    <pre>
    $display = time_since($stamp+21600);
    </pre>
    Thanks
    Karl

    kashirow

    (@kashirow)

    He tells you to call the time_since function with the value of the $stamp seconds from 1st of January 1970 increased by 21600 (which is 6 hours worth of time) and put the result into the variable $display.
    This won’t do you any good unless you actually set the variable $stamp first, and use the $display in some way, naturally. ?? Notice: the_time(‘U’,”,”,false) will give you the seconds for the current post.

    Thread Starter karlb

    (@karlb)

    Ah ??
    Dare I ask how I would set the variable stamp? ??
    Thanks
    Karl

    kashirow

    (@kashirow)

    Reading the documentation on https://www.php.net will be very helpful. Spoonfeeding even the most trivial things is not many people’s idea of fun. ?? PHP is really not a complex language by itself.
    $stamp = the_time(‘U’,”,”,false);

    Thread Starter karlb

    (@karlb)

    Hey Guys,
    I have been unable to get this to work but many thanks for your efforts ??
    I think it is my lack of PHP knowlege.
    Karl

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘TC SERVO: How did you set up date since?’ is closed to new replies.