Date format for blog posts

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #35820
    polf0001
    Participant

    Hello, I want to change the date on blog posts so it includes the year as well as the month and day. I asked this question in 2016 and got an answer, but it no longer works with the revised theme. Can you tell me where to change the php, please? The 2016 question is here:

    https://support.livemeshthemes.com/forums/topic/date-format-for-blog-posts/

    Thanks!

    #35821
    Raghavendra
    Moderator

    Can you pls have this file of the parent theme in your child theme and modify the same to your needs?

    templates/meta/published.php

    #35824
    polf0001
    Participant

    Thanks, Raghanendra. OK: I have had a look at this php. Here it is. Can you tell me what to edit, please? I just want it to add the year to the month and the day.

    <?php

    $format = “M d, Y”;

    ?>

    <span class=”published”>

    <?php echo __(‘On: ‘, ‘extinct’); ?>


    title=”<?php echo sprintf(get_the_time(esc_html__(‘l, F, Y, g:i a’, ‘extinct’))); ?>”><?php echo get_the_time($format); ?>

    </span>

    #35825
    polf0001
    Participant

    Screenshot attached to give line numbers.

    [attachment file=”35826″]

    #35829
    Raghavendra
    Moderator

    I hope this is resolved as I saw the year in the PHP. If not, please reach out to us and we will help.

    #35830
    polf0001
    Participant

    Thanks. Sorry, I’m afraid it’s not resolved! That’s the php file as it now is, unedited, and the year doesn’t appear.

    Here’s the site: https://www.paper-darts.com/news/

    It’s the little red tab on the blog items – it says SEP 30 – where it should be SEP 30 2020.

    best wishes,

    Nick

    #35845
    Raghavendra
    Moderator

    You need to create a new file named published-custom.php in templates/meta/ folder and have the following content in the same to make the year appear in the desired place –

    <?php
    
    ?>
    
    <span class="published">
         <abbr title="<?php echo sprintf(get_the_time(esc_attr__('l, F, Y, g:i a', 'extinct'))); ?>">
             <span class="month"><?php echo sprintf(get_the_time('M')); ?></span>
             <span class="date updated"><?php echo sprintf(get_the_time('d, Y')); ?></span>
         </abbr>
    </span>
    
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Extinct Theme Support’ is closed to new topics and replies.