Forums

the_time formatting is not working (5 posts)

  1. acumplido
    Member
    Posted 1 year ago #

    Hi all,

    I've crated a customized breadcrumb in the archives template. What I want is display in the breadcrumb a title like "Archive for March". Everything works perfect, except the the_time formatting. Despite of what format I apply, I always get the same formatting, i.e. "Month dd, yyyy". In the example below, I've also pasted another test that I made with get_the_time which it just doesn't work.

    <?php if (have_posts()) : ?>
    
     			<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    
    			<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    				<h2>Archive for <?php the_time('F, Y'); ?></h2>
    
    			<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    				<h2>Archive for <?php get_the_time('F, Y', $post->ID); ?></h2>
    
    		<?php } ?>

    What should I do? Any help is welcomed.
    Many thanks

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    <h2>Archive for <?php echo get_the_time('F, Y', $post->ID); ?>

  3. acumplido
    Member
    Posted 1 year ago #

    Excellent!
    Many thanks esmi.

    As you can see, I'm not an expert :-(
    If possible, can you let me know why:
    1. "<?php the_time('F, Y'); ?>" doesn't use echo?
    2. The formatting for "<?php the_time('F, Y'); ?>" doesn't work?

    Thanks again,
    a

  4. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    1. the_time function echoes the output as part of the function.

    2. It works just fine for me.

  5. acumplido
    Member
    Posted 1 year ago #

    Hi esmi,

    Many thanks again for your answers!
    Appreciate your help

Topic Closed

This topic has been closed to new replies.

About this Topic