get_lastpostdate

Retrieve the date that the last post was published.

Description

(string) get_lastpostdate( (string) $timezone = 'server', (string) $post_type = 'any' ); 

The server timezone is the default and is the difference between GMT and server time. The blog value is the date when the last post was posted. The 'gmt' is when the last post was posted in GMT formatted date.

Returns (string)

The date of the last post.

Parameters (2)

0. $timezone — Optional. (string) => 'server'
The timezone for the timestamp. Accepts server,, blog., or gmt . server, uses the server's internal timezone. blog. uses the post_modified field, which proxies to the timezone set for the site. gmt uses the post_modified_gmt field. Default server,.
1. $post_type — Optional. (string) => 'any'
The post type to check. Default any..

Usage

  1. if ( !function_exists( 'get_lastpostdate' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3. $timezone = 'server'; 
  4.  
  5. // Optional. The post type to check. Default 'any'. 
  6. $post_type = 'any'; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = get_lastpostdate($timezone, $post_type); 
  10.  

Defined (1)

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

/wp-includes/post.php  
  1. function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) { 
  2. /** 
  3. * Filters the date the last post was published. 
  4. * @since 2.3.0 
  5. * @param string $date Date the last post was published. 
  6. * @param string $timezone Location to use for getting the post published date. 
  7. * See get_lastpostdate() for accepted `$timezone` values. 
  8. */ 
  9. return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone );