没有显示human_time_diff的输出

时间:2019-05-09 15:54:11

标签: php

我正尝试使用human_time_diff来显示发布内容多久了。

我正在这样获取ACF字段:

<?php $commenttime = get_sub_field( 'time', $postid ); ?>

我为$commenttime返回的格式为:

Y-m-d H:i:s

但是当我这样做时,没有显示时差:

<?php echo human_time_diff( $commenttime, current_time('timestamp') ) . ' ago'; ?>

我要去哪里错了?

1 个答案:

答案 0 :(得分:1)

  

fromfile():确定两个时间戳之间的差异

#!/usr/bin/env python3

import numpy as np
from PIL import Image

# Define width and height
w, h = 50, 100

# Read file using numpy "fromfile()"
with open('data.bin', mode='rb') as f:
    d = np.fromfile(f,dtype=np.uint8,count=w*h).reshape(h,w)

# Make into PIL Image and save
PILimage = Image.fromarray(d)
PILimage.save('result.png')

此功能的使用

human_time_diff

变量human_time_diff( $from, $to ) 应该带有时间戳记

human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago';