Answer the question
In order to leave comments, you need to log in
How to display the current date, in the format "1 hour ago", "two weeks ago", etc.?
Greetings!
Can you please tell me a PHP class for displaying a date in a format like VK, depending on a pre-set date? It is desirable that he be friends with the Russian language / cases.
That is, not "May 22, 2016, 13:00", but "30 minutes ago" (and so on).
Thank you in advance.
Answer the question
In order to leave comments, you need to log in
Use https://github.com/briannesbitt/Carbon
Namely, you need the diffForHumans method. Under carbon there are a bunch of locales and translations, you will find it for any language.
In addition, you will have to work with dates more than once, include Carbon in your projects anyway. Will always come in handy.
This is done not in PHP, but in JS, the usual date is displayed in php, JS formats it by replacing the contents of the block with a new one
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question