我試圖用它human_time_diff來顯示多久前發(fā)布了一些東西。我得到這樣的 ACF 字段:<?php $commenttime = get_sub_field( 'time', $postid ); ?>我的返回格式$commenttime是:Y-m-d H:i:s但是當(dāng)我這樣做時(shí),沒有顯示時(shí)差:<?php echo human_time_diff( $commenttime, current_time('timestamp') ) . ' ago'; ?>我哪里錯(cuò)了?
1 回答

瀟瀟雨雨
TA貢獻(xiàn)1833條經(jīng)驗(yàn) 獲得超4個(gè)贊
human_time_diff
:確定兩個(gè)時(shí)間戳之間的差異
human_time_diff( $from, $to )
這個(gè)功能的使用
human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago';
變量$commenttime
應(yīng)該在時(shí)間戳中
strtotime($commenttime)
- 1 回答
- 0 關(guān)注
- 138 瀏覽
添加回答
舉報(bào)
0/150
提交
取消