distance_of_time_in_words(strtotime(2010-08-07), strtotime(2010-08-01))
returns '6 minutes'
$a = '2010-08-02 00:39:29'
$b = '2010-08-01'
distance_of_time_in_words($a, $b)
returns 'less than a minute'
$a = '2010-08-02 00:39:29'
$b = '2010-08-01 20:08:00'
distance_of_time_i开发者_StackOverflown_words($a, $b)
returns 'less than a minute'
I wonder if I'm going wrong in the conversion.. Does it accept a timestamp or date? Thanks
Checking it's source code it seems it needs timestamps (it does some calculations at the beginning of the function).
// call
distance_of_time_in_words(getUnixTimestamp(), getUnixTimestamp($bill->created_at));
// utility method
public function getUnixTimestamp($datetime = null)
{
return date("U", (($datetime) ? strtotime($datetime) : time()));
}
Hope this will help others!
精彩评论