WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP and last updated Time (4 posts)

  1. estjohn
    Member
    Posted 5 years ago #

    Hello. Normally when I create a non WordPress website, I add
    `<?php date_default_timezone_set("EST"); echo date ("Y-m-j h:i:s A (T)", getlastmod()); ?>'

    To the bottom of the page to show when the page was last updated.

    But, for some reason, when I use it in single, archive, or index on any theme in WordPress, it shows the same date for all posts. I *kinda* can see why it would do that on the archive and index - it is showing the last time the index.php and archive.php was updated - not the actual post. But I am also trying to figure out if it is doing the same for single - displaying the last time single.php was modified and not the actual post itself.

    I am using this on http://www.aleeya.net and have tried multiple themes, it does the same in each. I was placing it just under
    'Posted on <span class="bold"><?php the_time('l, jS F Y'); ?></span> by <span class="bold"><?php the_author(); ?></span>'

    On Single.php

    I am trying to move the code and see if that changes it.

    I have been searching for a plugin that would remedy this or some other way I can post it.

    Does anyone have any ideas?

  2. estjohn
    Member
    Posted 5 years ago #

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    A simpler way would have been to use the_modified_time() or the_modified_date() functions in your theme. No plugin necessary. They work exactly like the_time() and the_date() functions do.

  4. estjohn
    Member
    Posted 5 years ago #

    Oh wow Great! I will look into that and see if I can implement it that way. Plugins are wonderful, but if I can find a way to tweak it without a plugin, its even better (in case the plugin breaks in a future version)

    Thank you Otto, I completely missed that in my searches!

Topic Closed

This topic has been closed to new replies.

About this Topic