• Resolved Ephramar

    (@krzheiyah)


    Apparently, WordPress functions like the_date() and the_time() displays or returns the date of a post

    But what if, I had to display a set of posts if published on the same day? It’ll be awkward to display the same dates all over the time

    Do WordPress has the date/time function which supports displays of strings like

    Today at 8:40pm
    Yesterday at 10:40pm

    Do I need to make my own function for the date/time appending my desired strings and use only ‘the_time’ function?

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you use the_date(), only the most recent post published on a given day will display the date/timestamp. Otherwise, you will need to create your own function for the date/time.

    Thread Starter Ephramar

    (@krzheiyah)

    I made out this function just to help me format the time. This code isn’t optimized yet

    add_filter on the_date maybe optional

    Thanks to @esmi for helping me with the idea
    //Resolved

    Code Snippet could be seen here

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display 'Today' and 'Yesterday' in WordPress Posts’ is closed to new replies.