WordPress at a glance

the_time() WP 0.71

Display the time (date) at which the post was written in the specified format.

This function must be used inside the Loop of WordPress.

The function is identical to the function: the_date().

Works based on: get_the_time()
Hooks from the function

Nothing (null). The result is displayed.


<?php the_time( $d ); ?>
Date format (in PHP syntax). For example, j F Y will print "12 December 2010". More information about date formatting in PHP.
Default: '' (time_format option)


#1 Output the time of publication of the post

This entry was posted: <?php the_time(); ?>

#2 Time in "24 hour" and "AM/PM" formats

Let's output the time at which the post was written in the format "24 hours" (23: 12):

<p>Publish time: <?php the_time('G:i'); ?></p>

If you want to output in AM/PM format:

<p>Publish time: <?php the_time('g:i a'); ?></p>

#3 Display the date (not time)

the_time() in addition to the time can display the date, you only need to specify a format:

<div><?php the_time('j F Y'); ?></div>

Список изменений

С версии 0.71 Введена.

Code of the_time() WP 5.5.1

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 );

Related Functions

From tag: WP Loop

More from tag: date time

More from category: Posts, pages...

More from Template Tags: Posts, Pages, ...

vladlu 100vlad.lu
Editors: kama 100
No comments
    Log In . Register