get_the_modified_date

Retrieve the date on which the post was last modified.

Description

(false|string) get_the_modified_date( (string) $d = '', (null) $post = null ); 

Returns (false|string)

Date the current post was modified. False on failure.

Parameters (2)

0. $d — Optional. (string) => ''
PHP date format defaults to the date_format option if not specified.
1. $post — Optional. (null) => null
Post ID or WP_Post object. Default current post.

Usage

  1. if ( !function_exists( 'get_the_modified_date' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4. // Optional. PHP date format defaults to the date_format option if not specified. 
  5. $d = ''; 
  6.  
  7. // Optional. Post ID or WP_Post object. Default current post. 
  8. $post = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_the_modified_date($d, $post); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. function get_the_modified_date( $d = '', $post = null ) { 
  2. $post = get_post( $post ); 
  3.  
  4. if ( ! $post ) { 
  5. // For backward compatibility, failures go through the filter below. 
  6. $the_time = false; 
  7. } elseif ( empty( $d ) ) { 
  8. $the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true ); 
  9. } else { 
  10. $the_time = get_post_modified_time( $d, false, $post, true ); 
  11.  
  12. /** 
  13. * Filters the date a post was last modified. 
  14. * @since 2.1.0 
  15. * @since 4.6.0 Added the `$post` parameter. 
  16. * @param string $the_time The formatted date. 
  17. * @param string $d PHP date format. Defaults to value specified in 
  18. * 'date_format' option. 
  19. * @param WP_Post $post WP_Post object. 
  20. */ 
  21. return apply_filters( 'get_the_modified_date', $the_time, $d, $post );