Muốn hiển thị ngày giờ của bài viết trong wordpress ta sử dụng hàm như sau (thêm vào function)
/** codfe.com hien thai ngay gio post**/
function ash_relative_time() {
$post_date = get_the_time('U');
$delta = time() - $post_date;
if ( $delta < 60 ) {
echo 'Just Now';
} elseif ($delta > 60 && $delta < 120) {
echo '1 minute ago';
} elseif ($delta > 120 && $delta < (60*60)) {
echo strval(round(($delta/60),0)), ' minutes ago';
} elseif ($delta > (60*60) && $delta < (120*60)) {
echo 'About an hour ago';
} elseif ($delta > (120*60) && $delta < (24*60*60)) {
echo strval(round(($delta/3600),0)), ' hours ago';
} else {
echo the_time('j\<\s\u\p\>S\<\/\s\u\p\> M y g:i a');
}
}
Sử dung bằng cách thêm hàm ash_relative_time() vào khu vực muốn hiển thị nhé!
Bài viết mới:
- Effektive Lösungen the-wingaga.com.de für moderne Geschäftsprozesse und digitale Transformation
- Aktuelle Strategien und thebets24casino.com für innovative Glücksspiel-Erlebnisse
- Hiển thị tất cả comment trong web wordpress, các tham biến của hàm WP_Comment_Query wordpress,
- Vibrant gaming journeys await players exploring luckcasino1.co.uk and its diverse selection
- Code nút liên hệ





