0

Suppose if a date is in the format

2018-10-10 16:24:52

How to get time ago format for this date as

2 days ago

..

If date format is 2018-09-10 16:24:52 The date format should be 1 month ago and if 2017-10-10 16:24:52 The date format should be 1 year ago

How to achieve this in PHP?

Pavithra
  • 129
  • 1
  • 2
  • 13

1 Answers1

0

Try this library - https://github.com/jenssegers/date

From README.md -

Get a human readable output (alias for diffForHumans):

echo $date->ago(); // 5 days ago
Saharsh
  • 1,056
  • 10
  • 26