Example 1 — Default date
Print the date in the site format.
<span class="date"><?php comment_date(); ?></span> How It Works
- No format is given.
- WordPress uses the date format from your settings.
- The date is printed as plain text.

In WordPress, comment_date() prints the date when a comment was posted.
By default it uses the date format from Settings → General. You can pass a PHP date format to change it.
Call it with no format for the site format, or pass a PHP date format.
comment_date();
comment_date( 'd/m/Y' );
comment_date( 'F j, Y', 15 ); | Call | What it does |
|---|---|
comment_date() | Prints the date in the site's date format. |
comment_date( 'd/m/Y' ) | Prints the date in your own format. |
comment_date( 'F j, Y', 15 ) | Prints the date of comment 15. |
Use comment_time() to print the time of the comment.
comment_date( string $format = '', int|WP_Comment $comment_id = 0 ): void | Parameter | Description |
|---|---|
$format | Optional. A PHP date format. If empty, WordPress uses the date_format option. |
$comment_id | Optional. A comment ID or WP_Comment object. Default is the current comment. |
| Return Value | Description |
|---|---|
| void | Nothing is returned. The function prints the date. |
Three short theme examples. Each one has a sample output.
Print the date in the site format.
<span class="date"><?php comment_date(); ?></span> Print the date as day/month/year.
<span class="date"><?php comment_date( 'd/m/Y' ); ?></span> d is the day, m is the month, Y is the year.Build a time tag with the date and the time.
<time datetime="<?php echo esc_attr( get_comment_date( 'c' ) ); ?>">
<?php comment_date(); ?> at <?php comment_time(); ?>
</time> get_comment_date( 'c' ) returns a machine-readable date.comment_date() prints the friendly date.comment_time() prints the time.Print a short plain-text excerpt of the current comment.
10 people found this page helpful