-3

With the following line i get a DATE in Y-m-d format.

echo date('Y-m-d',strtotime($result["created_at"]));

Its the creation date of an account. now id like to calculate how old the account is so i can print it out like 5 Years, 5 Months as a example.

any ideas?

user3220962
  • 371
  • 1
  • 7
  • 19

1 Answers1

2

Try this: create a current date and use the difference.

$currentDate = new Date();
$interval = $currentDate->diff(new Date($result["created_at"]));
echo $interval->y . ' years and ' . $interval->m . ' months';
Nitin
  • 898
  • 1
  • 9
  • 25