Please tell me how to implement this: I create news in the table, in addition to other information, I add time, how can I make it so that the time and date would be in this format:

after the addition is added 10 seconds ago and so on ... The next day in this format: Added: Yesterday at 20:21, etc., well, 2 days have passed from the moment of adding to write ... as it were constantly updated. Added 6 February 20:21

Thanks a lot who will help :)

    2 answers 2

    Why is it updated in the database ??? Store in the timestamp database and output as you like ... You just imagine if you have 1 million news :) You will need to buy non-weak servers in order to update ALL records every second.

    ps; somewhere here I have already seen a similar question. read about datetime
    pps; in short, the essence: $seconds_from_other_date = time() - $your_timestamp_in_db; in the variable, you get the number of seconds elapsed since the publication.
    ppps; mini example

      IMHO crazy idea to constantly update it in the database, do as written @thunder , store in the timestamp database, and then when forming the page, convert the script as you need. Look towards the date () function.