• Resolved snippet24

    (@snippet24)


    I don’t intend to retrieve the date from WordPress published admin date, but rather for every time I edit directly the content in the template. I know how to do it in JS with javascript:alert(document.lastModified) but I would rather PHP use instead, and if posible in the format year-month-day

    Have tried so far:

    <?php echo date("Y F d", getlastmod()); ?>
    
    <?php echo get_post_field( 'post_modified', 288 ); ?>
    
    <?php get_the_modified_date();?>
    • This topic was modified 1 year, 7 months ago by snippet24.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Kai Hao

    (@kevin940726)

    get_the_modified_time should work. Maybe you’re missing echo? Try this:

    <?php echo get_the_modified_time('Y-m-d'); ?>

    See the reference of get_the_modified_time for more info.

    Thread Starter snippet24

    (@snippet24)

    Thank you. Well it retrieves an incorrect date: 2022-11-29 And I just modified the template now..

    Thread Starter snippet24

    (@snippet24)

    Ok update: while it retrieves an incorrect date running in localhost it works properly on the live server

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to retrieve the last modified date for a template.’ is closed to new replies.