<?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?>
Oben ist der Standardcode, der für comments.php im WP Core existiert.
Dies erzeugt eine Ausgabe wie diese:
1. Oktober 2017 um 6:58 Uhr
Aber ich möchte so etwas →
Gepostet: vor 11 Monaten
oder
Gepostet vor 3 Tagen Zurück
oder
Gepostet vor 23 Stunden
Ist es möglich, diese beiden zusammenzuarbeiten:
get_comment_date(), get_comment_time()
um den oben genannten Effekt zu erzielen?
Was Sie brauchen, ist: https://codex.wordpress.org/Function_Reference/human_time_diff
Das sollte also genau das tun, was Sie brauchen:
<?php printf( _x( '%s ago', '%s = human-readable time difference', 'your-text-domain' ), human_time_diff( get_comment_time( 'U' ), current_time( 'timestamp' ) ) ); ?>