WordPress:Template Tags/get the time

来自站长百科
Xxf3325讨论 | 贡献2008年6月25日 (三) 11:30的版本 (新页面: == Description == Returns the time of the current post for use in PHP. It does not display the time. This tag must be used within WordPress:The Loop. This...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

Description

Returns the time of the current post for use in PHP. It does not display the time. This tag must be used within WordPress:The Loop.

This tag is available beginning with version 1.5 of WordPress. To display the time of a post, use the_time().

Usage

%%% <?php get_the_time('format'); ?> %%%

Examples

Default Usage

Returns the time of the current post using the WordPress default format, and displays it using the PHP echo command.

<?php echo get_the_time(); ?>

Assigns Time in Seconds

Assigns the time of the current post in seconds (since January 1 1970, known as the Unix Epoch) to the variable $u_time.

<?php $u_time = get_the_time('U'); ?>


Parameters

format
(string) The format the time is to display in. Defaults to the time format configured in your WordPress options. See WordPress:Formatting Date and Time.

Related

See also the_time().

模板:Tag Date Tags

模板:Tag Footer