1
我想知道PHP是否有内置函数来返回日期的相关性。例如:从时间戳(即今天,明天)获取相对日期
$timestamp = time();
$other = time()+86400;
echo rel_date($timestamp); //prints Today
echo rel_date($other); //prints Tomorrow
我知道这是非常简单的功能,但我不想重新发明轮子!
我想知道PHP是否有内置函数来返回日期的相关性。例如:从时间戳(即今天,明天)获取相对日期
$timestamp = time();
$other = time()+86400;
echo rel_date($timestamp); //prints Today
echo rel_date($other); //prints Tomorrow
我知道这是非常简单的功能,但我不想重新发明轮子!
据我所知,在具有格式选项,。OUPUTS“今天”,“昨天”,“明天”等功能,没有内置..
我做他们自己,因为这无论如何。看起来你需要自己构建它,毕竟,对不起:(
从['DateTime :: diff'开始 - 返回两个DateTime对象之间的区别](http://www.php.net/manual/ en/datetime.diff.php) – Gordon
如果将相关性定义为像今天的“接近度”那样,我会使用像相关性(curr,other)= 1 /(diffdays(curr,other)+1)^ 2。 – Timo