Good morning HashCode.

How to make a countdown of how much time has passed since (for example, adding news), I did so

$date = date("G:i:s", time() - $res["date"]) echo $date; 

But the trouble is that even if I add the current time to the database, the counting begins, and not from 0 hours 0 minutes and 0 seconds, but immediately as if I sent a message 2 hours ago, that is, the countdown does not go from zero, but from 2

    1 answer 1

     $date = date("G:i:s", time() - $res["date"]) echo $date; 

    I usually put H and not G

     G Часы в 24-часовом формате без ведущего нуля H Часы в 24-часовом формате с ведущим нулём time() Возвращает количество секунд 

    $ res ["date"] where does it come from?

    But rather, the question is precisely in the Letter at the conclusion.

    // UPD Well, in order not to make a garden, already answered the question here

    • From the Base, there are seconds too. - Angus123
    • I need something like this: 0:01:56, but it turns out 2:01:56 - Angus123
    • Updated the answer because a similar question has already been asked. - Artem Nov.
    • I have the following error: Fatal error: Call to undefined function date_diff () in Z: \ home \ koni.ru \ www \ add.php on line 15 - Angus123
    • Where are you there in the code on the link in my answer found about ** date_diff () ** ??? I am amazed, even if you give a link to the solution of the issue, you can step on the rake, more than once! - Artem Nov.