I am trying to display \"{number} {unit-of-time} ago\" in my chat. However, when I\'m expecting something like \"2 minutes ago\", I see \"45 years\" instead.
Nobody
You have to fetch the date:
$tm = mysql_query("SELECT timestamp AS t FROM logs ORDER by id ASC")->fetch_assoc()['t']; //obviously, check the size before you fetch
You probably want to use strtotime()
so for instance:
$dif = $cur_tm-strtotime($tm);
The $dif
will be in milliseconds.
What are you doing with the loops and the arrays? Too confusing.
mysql_
!!!