Languages: English • 日本語 (Add your language)
Returns the time of the current post for use in PHP. It does not display the time. To display the time of a post, use the_time(). This tag must be used within The Loop.
<?php get_the_time( $format, $post ); ?>
$post
objectReturns the time of the current post using the WordPress default format, and displays it using the PHP echo command.
<?php echo get_the_time(); ?>
Returns the time of the post with ID $post->ID in the WordPress default format.
<?php echo get_the_time('', $post->ID); ?>
Assigns the local time of the current post in seconds (since January 1 1970, known as the Unix Epoch) to the variable $local_timestamp .
<?php $local_timestamp = get_the_time('U'); ?>
In most cases, you would probably want the epoch time for GMT (rather than for the local time zone), which you can get with the get_post_time() function, setting the $gmt
option to true
:
<?php $gmt_timestamp = get_post_time('U', true); ?>
get_the_time() is located in wp-includes/general-template.php
get_calendar(), get_day_link(), get_month_link(), get_the_date(), get_the_time(), get_year_link(), single_month_title(), the_date(), the_date_xml(), the_modified_date(), get_the_modified_date(), the_modified_time(), get_the_modified_time(), the_time()