函数原型
get_post_timestamp( int|WP_Post $post = null, string $field = ‘date’ ): int|false
函数描述
Retrieves post published or modified time as a Unix timestamp.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post
Optional - Post ID or post object. Default is global
$postobject.Default:
null -
$field
string
Optional - Published or modified time to use from database. Accepts
'date'or'modified'.
Default'date'.Default:
'date'
函数返回值
int|false Unix timestamp on success, false on failure.
函数位置
File: wp-includes/general-template.php.
函数源码
function get_post_timestamp( $post = null, $field = 'date' ) {
$datetime = get_post_datetime( $post, $field );
if ( false === $datetime ) {
return false;
}
return $datetime->getTimestamp();
}
源码链接
变更日志
| Version | Description |
|---|---|
| 5.3.0 | Introduced. |

