get_the_modified_time

Retrieve the time at which the post was last modified.

Description

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

Returns (false|string)

Formatted date string or Unix timestamp. False on failure.

Parameters (2)

0. $d — Optional. (string) => ''
Format to use for retrieving the time the post was modified. Either G,, U, or php date format defaults to the value specified in the time_format option. Default empty.
1. $post — Optional. (null) => null
Post ID or WP_Post object. Default current post.

Usage

  1. if ( !function_exists( 'get_the_modified_time' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3. $d = ''; 
  4.  
  5. // Optional. Post ID or WP_Post object. Default current post. 
  6. $post = null; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = get_the_modified_time($d, $post); 
  10.  

Defined (1)

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

/wp-includes/general-template.php  
  1. function get_the_modified_time( $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( 'time_format' ), false, $post, true ); 
  9. } else { 
  10. $the_time = get_post_modified_time( $d, false, $post, true ); 
  11.  
  12. /** 
  13. * Filters the localized time a post was last modified. 
  14. * @since 2.0.0 
  15. * @since 4.6.0 Added the `$post` parameter. 
  16. * @param string $the_time The formatted time. 
  17. * @param string $d Format to use for retrieving the time the post was 
  18. * written. Accepts 'G', 'U', or php date format. Defaults 
  19. * to value specified in 'time_format' option. 
  20. * @param WP_Post $post WP_Post object. 
  21. */ 
  22. return apply_filters( 'get_the_modified_time', $the_time, $d, $post );