File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -1031,15 +1031,22 @@ function comment_text( $comment_ID = 0, $args = array() ) {
1031
1031
* Retrieves the comment time of the current comment.
1032
1032
*
1033
1033
* @since 1.5.0
1034
+ * @since 6.2.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
1034
1035
*
1035
- * @param string $format Optional. PHP time format. Defaults to the 'time_format' option.
1036
- * @param bool $gmt Optional. Whether to use the GMT date. Default false.
1037
- * @param bool $translate Optional. Whether to translate the time (for use in feeds).
1038
- * Default true.
1036
+ * @param string $format Optional. PHP date format. Defaults to the 'time_format' option.
1037
+ * @param bool $gmt Optional. Whether to use the GMT date. Default false.
1038
+ * @param bool $translate Optional. Whether to translate the time (for use in feeds).
1039
+ * Default true.
1040
+ * @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the date.
1041
+ * Default is 0, or the global comment.
1039
1042
* @return string The formatted time.
1040
1043
*/
1041
- function get_comment_time ( $ format = '' , $ gmt = false , $ translate = true ) {
1042
- $ comment = get_comment ();
1044
+ function get_comment_time ( $ format = '' , $ gmt = false , $ translate = true , $ comment_ID = 0 ) {
1045
+ $ comment = get_comment ( $ comment_ID );
1046
+
1047
+ if ( null === $ comment ) {
1048
+ return '' ;
1049
+ }
1043
1050
1044
1051
$ comment_date = $ gmt ? $ comment ->comment_date_gmt : $ comment ->comment_date ;
1045
1052
You can’t perform that action at this time.
0 commit comments