Wp_query year output

I am using wp query class to output the following
archive

<?php 
$archive_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1)); ?>
 
<?php if ( $archive_query->have_posts() ) : ?>
  <main class="archive">
 
       <?php while ( $archive_query->have_posts() ) : $archive_query->the_post(); ?>
        
       <div><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
       <div class ="date"><?php echo get_the_date(); ?></div>
       </div>

    <?php endwhile; ?>
   
    <?php wp_reset_postdata(); ?>
 
<?php else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

how can I modify the loop to show the year 2019, 2020 ?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.