the_time( string $format = '' )

Display the time at which the post was written.


Parameters Parameters

$format

(string) (Optional) Either 'G', 'U', or PHP date format.

Default value: ''


Top ↑

Source Source

File: wp-includes/general-template.php

function the_time( $format = '' ) {
	/**
	 * Filters the time a post was written for display.
	 *
	 * @since 0.71
	 *
	 * @param string $get_the_time The formatted time.
	 * @param string $format       The time format. Accepts 'G', 'U',
	 *                             or PHP date format.
	 */
	echo apply_filters( 'the_time', get_the_time( $format ), $format );
}


Top ↑

Changelog Changelog

Changelog
Version Description
0.71 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 3 content
    Contributed by Codex

    Time as AM/PM VS. 24H format

    Displays the time using the format parameter string ‘g:i a’ (ex: 10:36 pm).

    <p><?php _e( 'Time posted: ', 'textdomain' ) . the_time( 'g:i a' ) ); ?></p>
    

    Displays the time using the 24 hours format parameter string ‘G:i’ (ex: 17:52).

    <p><?php _e( 'Time posted: ', 'textdomain' ) . the_time( 'G:i' ) ); ?></p>
    

You must log in before being able to contribute a note or feedback.