views:

38

answers:

2
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_in_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

+1  A: 

Checking it's source code it seems it needs timestamps (it does some calculations at the beginning of the function).

Maerlyn
thanks for the pointer Maerlyn, yes it accepts the timestamp..
Prasad
A: 
// 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!

Prasad