0

I need the unix timestamp - the timestamp i have. Then display the time between like on twitter.

bmb
  • 6,058
  • 2
  • 37
  • 58
Tapha
  • 1,491
  • 3
  • 17
  • 32
  • possible duplicate of [Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago...](http://stackoverflow.com/questions/1416697/converting-timestamp-to-time-ago-in-php-e-g-1-day-ago-2-days-ago) – Glavić Jan 07 '14 at 13:33

3 Answers3

3

Not sure what language you need it, but if it will end up in a web page, you may try timeago.

Vaidas
  • 968
  • 9
  • 22
pgb
  • 24,813
  • 12
  • 83
  • 113
3

If you have the difference called diff:

$seconds = intval($diff) % 60;
$minutes = intval($diff/60) % 60;
$hours = intval($diff/3600) % 24;
$days = intval($diff/(3600*24));

Is this what you want ?

nc3b
  • 15,562
  • 5
  • 51
  • 63
0

Use example :

echo time_elapsed_string('@1367367755');
echo time_elapsed_string('@1367367755', true);

Output :

4 months ago
4 months, 2 weeks, 3 days, 1 hour, 49 minutes, 15 seconds ago

Link to the function.

Community
  • 1
  • 1
Glavić
  • 42,781
  • 13
  • 77
  • 107