get_post_timestamp() WP 5.3.0
Retrieve post published or modified time as a Unix timestamp.
Note that this function returns a true Unix timestamp, not summed with timezone offset like older WP functions.
Хуков нет.
Возвращает
Число/false. Unix timestamp on success, false on failure.
Использование
get_post_timestamp( $post, $field );
- $post(число/WP_Post)
- WP_Post object or ID.
По умолчанию: global $post object - $field(строка)
- Published or modified time to use from database. Accepts 'date' or 'modified'.
По умолчанию: 'date'
Список изменений
С версии 5.3.0 | Введена. |
Код get_post_timestamp() get post timestamp WP 5.6.2
function get_post_timestamp( $post = null, $field = 'date' ) {
$datetime = get_post_datetime( $post, $field );
if ( false === $datetime ) {
return false;
}
return $datetime->getTimestamp();
}