date format for blog posts

Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #19995
    polf0001
    Participant

    Hello. Please is there any way to change the date displayed on blog posts so it includes the year? I need to change it from the j, M format (e.g. today’s date = 14 Mar) to j, M, Y format (14 Mar 2016)? Many thanks for your help!

    #19997
    Veena
    Moderator
    #20001
    polf0001
    Participant

    Thanks for this. Can you give me a bit more help with the php code, please? If I want to add the year, do I change this:

    $published = ‘<span class=”published”><abbr title=”‘ . sprintf(get_the_time(esc_attr__(‘l, F, Y, g:i a’, ‘mo_theme’))) . ‘”><span class=”month”>’ . sprintf(get_the_time(‘M’)) . ‘</span><span class=”date updated”>’ . sprintf(get_the_time(‘d’)) . ‘</span></span></abbr></span>’;

    to this:

    $published = ‘<span class=”published”><abbr title=”‘ . sprintf(get_the_time(esc_attr__(‘l, F, Y, g:i a’, ‘mo_theme’))) . ‘”><span class=”month”>’ . sprintf(get_the_time(‘M’)) . ‘</span><span class=”date updated”>’ . sprintf(get_the_time(‘d’)) . ‘<span class=”year”>’ . sprintf(get_the_time(‘Y’)) . ‘</span></span></abbr></span>’;

    #20009
    Veena
    Moderator

    Pls modify line no:72 to

     $published = '' . sprintf(get_the_time('d')) . '' . sprintf(get_the_time('M')) . '' . sprintf(get_the_time('Y')) . '';
    
    #20013
    polf0001
    Participant

    Sorry: I’ve tried this but it just makes the date disappear altogether! (Is it definitely a ‘d’ and not a ‘j’ by the way?)

    #20014
    polf0001
    Participant

    Actually, this seems to work:

    $published = ‘<span class=”published”><abbr title=”‘ . sprintf(get_the_time(esc_attr__(‘l, F, Y, g:i a’, ‘mo_theme’))) . ‘”><span class=”date updated”>’ . sprintf(get_the_time(‘d’)) . ‘</span><span class=”month”>’ . sprintf(get_the_time(‘M’)) . ‘</span><span class=”date updated”>’ . sprintf(get_the_time(‘Y’)) . ‘</span></abbr></span>’;

    #20025
    Veena
    Moderator

    Have you resolved this ?

    #20032
    polf0001
    Participant

    Yes, thanks, I think it works with that revised line 72.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘date format for blog posts’ is closed to new replies.