invp_get_the_last_modified( int|null $post_ID = null )

invp_get_the_last_modified


Description Description

Template tag. Returns the timestamp the vehicle was last modified formatted as a string according to WordPress' date and time format as set at Settings → General.


Top ↑

Parameters Parameters

$post_ID

(int|null) (Optional) The post ID of a vehicle. Must be passed when using this method outside the loop.

Default value: null


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/template-tags.php

function invp_get_the_last_modified( $post_ID = null ) {
	if ( empty( $post_ID ) ) {
		$post_ID = get_the_ID();
	}

	$date_format = get_option( 'date_format' );
	$time_format = get_option( 'time_format' );

	// Mon, 25 Apr 2022 01:45:46 -0400
	$date = DateTime::createFromFormat( 'D, d M Y h:i:s O', invp_get_raw_last_modified() );

	if ( ! $date ) {
		return '';
	}

	return date( $date_format . ' ' . $time_format, $date->getTimestamp() );
}