V
V
Vladimir Novitsky2016-04-05 20:53:10
PHP
Vladimir Novitsky, 2016-04-05 20:53:10

How to make human post dates in WordPress?

Hello.
The task is this:

  • if published within a minute, then only that is displayed ;
  • if published from a minute to an hour, then 25 minute(s)(s) ago are displayed ;
  • if published today, it is displayed today at 21:00 ;
  • if yesterday, then yesterday at 21:00 ;
  • if this year, then April 4 at 21:00 ;
  • if not this year, then April 4, 2014 at 21:00 .

On one site I found something similar, but it was crookedly done and not for WP.
It needs to be able to be placed in functions.php.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rikcon, 2016-04-05
@Rikcon

On the edge of momentjs.com

D
Dmitry, 2016-04-05
@dimasmagadan

you need a function like this
https://codex.wordpress.org/Function_Reference/hum...

G
glamurchik, 2016-04-06
@glamurchik

this is pure php, what for do you need wordpress? (hand face)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question