返回介绍

the_modified_date()

发布于 2017-09-11 10:35:57 字数 4429 浏览 1063 评论 0 收藏 0

the_modified_date( string $d = '',  string $before = '',  string $after = '',  bool $echo = true )

Display the date on which the post was last modified.


description


参数

$d

(string) (Optional) PHP date format defaults to the date_format option if not specified.

Default value: ''

$before

(string) (Optional) Output before the date.

Default value: ''

$after

(string) (Optional) Output after the date.

Default value: ''

$echo

(bool) (Optional) default is display. Whether to echo the date or return it.

Default value: true


返回值

(string|void) String if retrieving.


源代码

File: wp-includes/general-template.php

function the_modified_date( $d = '', $before = '', $after = '', $echo = true ) {
	$the_modified_date = $before . get_the_modified_date($d) . $after;

	/**
	 * Filters the date a post was last modified for display.
	 *
	 * @since 2.1.0
	 *
	 * @param string $the_modified_date The last modified date.
	 * @param string $d                 PHP date format. Defaults to 'date_format' option
	 *                                  if not specified.
	 * @param string $before            HTML output before the date.
	 * @param string $after             HTML output after the date.
	 */
	$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );

	if ( $echo )
		echo $the_modified_date;
	else
		return $the_modified_date;

}

更新日志

Versiondescription
2.1.0Introduced.

相关函数

Uses

  • wp-includes/general-template.php: get_the_modified_date()
  • wp-includes/general-template.php: the_modified_date
  • wp-includes/plugin.php: apply_filters()

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    Default Usage
    Displays the date the post was last modified, using the Default date format setting (e.g. F j, Y) from Administration > Settings > General.

    
    <p><?php printf( __( 'Last modified: %s', 'textdomain' ), get_the_modified_date() ); ?></p>
    

    Last modified: December 2, 2006

  2. Date as Month Day, Year
    Displays the last modified date in the date format ‘F j, Y’ (ex: December 2, 2006).

    
    <div><?php printf( __( 'Last modified: %s', 'textdomain' ), get_the_modified_date( 'F j, Y' ) ); ?></div>
    

    Last modified: December 2, 2006

    Date and Time
    Displays the date and time.

    
    <p><?php printf( __( 'Modified: %1$s at  %2$s', 'textdomain' ),
    	get_the_modified_date( 'F j, Y' ) ),
    	get_the_modified_date( 'g:i a' )
    ); ?></p>
    

    Modified: December 2, 2006 at 10:36 pm

    Date with superscript or subscript number suffixes
    Displays the date with a superscript or subscript st, nd, rd or th after the day. Because characters from the alphabet are used to represent the date format types, each of the HTML tag characters need to be escaped using a back slash. Superscript HTML tag is <sup> and subscript is <sub>.

    
    <p><?php printf( __( 'Modified: %s', 'textdomain' ), get_the_modified_date('j\<\s\u\p\>S\<\/\s\u\p\> M Y') ); ?></p>
    

    Modified: 2nd Dec 2006

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文