I would like to change the date format for one element of one of my site's pages.
Here is the current code:
<?php
/*
Template name: Auctions Diary
*/
get_header(); ?>
<?php do_action( 'flatsome_before_page' ); ?>
<style scope="scope">
#pagination a {
position: relative;
display: inline-block;
text-transform: uppercase;
font-size: .97em;
letter-spacing: .03em;
cursor: pointer;
font-weight: bolder;
text-align: center;
color: currentColor;
text-decoration: none;
border: 1px solid transparent;
vertical-align: middle;
border-radius: 0;
margin-top: 0;
margin-right: 1em;
text-shadow: none;
line-height: 2.4em;
min-height: 2.5em;
padding: 0 1.2em;
max-width: 100%;
box-sizing: border-box;
color: #fff;
background-color: #24691b;
border-radius: 99px;
}
.det-link {
font-size: 11px;
font-weight: bold;
background-color: #ffffff;
color: #0a612b;
padding: 2px;
width: 70px;
border: 1px solid #2c3691;
margin-top: 2px;
margin-bottom: 2px;
text-align: center;
}
.det-link a{
color: #0a612b;
}
.det-link a:hover {color: #fe1307;}
</style>
<div id="content" role="main" class="content-area">
<?php echo do_shortcode('[section padding="0px"][page_header title="Auctions Diary" bg_color="#7a9c59"][/section]'); ?>
<div class="row">
<div class="col small-12 large-12">
<table>
<tbody>
<?php
$loop = new WP_Query(array(
'post_type' => 'auctions_diary',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'auction_status',
'value' => 'active',
'compare' => '='
),
// array(
// 'key' => 'auction_date',
// 'value' => date('d-m-Y') . ' 00:00:00',
// 'type' => 'DATE',
// 'compare' => '>=',
// )
),
'meta_key' => 'auction_date',
'orderby' => 'meta_value',
'order' => 'ASC'
));
$date = "";
$status = true;
while($loop->have_posts()) : $loop->the_post();
if ($date != (string) date('F Y', strtotime(get_field('auction_date')))) {
$date = date('F Y', strtotime(get_field('auction_date')));
$status = true;
}
if ($status) {
echo "<tr><th style='border-bottom: 2px solid #24691b; font-size: 20px;'>". date('F Y', strtotime(get_field('auction_date'))) ."</th><th><br><br><br></th><th></th><th></th></tr>";
$status = false;
}
?>
<tr>
<td><strong><?php the_field('auction_date'); ?></strong> <?php the_field('auction_start_time'); ?></td>
<td><?php the_title(); ?></td>
<td><div class="det-link"><a href="<?php the_permalink(); ?>">Details</a></div></td>
<?php
$auction_id = get_field('auction_id');
$catalogues = new WP_Query(array(
'post_type' => 'catalogue',
'meta_query' => array(
array(
'key' => 'auction',
'value' => $auction_id
)
)
));
echo "<td>";
if ((int) $catalogues->found_posts > 0) {
$id = get_the_ID();
echo "<div class='det-link'><a href='". home_url('/catalogues/?id=' . get_field('auction_id', get_the_ID())) ."&auction=$id'>Catalogue </a></div>";
}
echo "</td>";
?>
</tr>
<?php endwhile; wp_reset_query(); ?>
</tbody>
</table>
</div>
</div>
</div>
<?php do_action( 'flatsome_after_page' ); ?>
<?php get_footer(); ?>
Line 99 of the code is the bit I need to change:
<td><strong><?php the_field('auction_date');
Currently it is displaying the date in the format: June 17, 2021 But I would like to change this to: 17 June, 2021
I have updated the date / time settings in Wordpress but this does not seem to affect it.
I am also conscious that I need to change the format just for this line because the field 'auction_date' is used elsewhere in the code and I do not want to affect that.
Any idea how I can make this change please?
Many thanks