Home › Forums › General Issues › Display day and month from date_picker field. › Reply To: Display day and month from date_picker field.
This isn’t really an ACF question. More of an general PHP question 🙂 But I’ll try and help you anyway.
This code should do the trick:
<!-- EVENTOS -->
<div class="container">
<div class="row">
<div class="col-sm-12"><h2 class="seccion">Fotos</h2></div>
<?php
$today = current_time('Ymd');
$args = array(
'post_type' => 'evento',
'post_status' => 'publish',
'posts_per_page' => '-1',
'meta_query' => array(
array(
'key' => 'fecha_del_evento',
'compare' => '>=',
'value' => $today,
)
),
'meta_key' => 'fecha_del_evento',
'orderby' => 'meta_value',
'order' => 'ASC',
);
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
?>
<div class="col-sm-3">
<?php
$datetime_string = get_field('fecha_del_evento');
$datetime = new DateTime($datetime_string);
$month = date_i18n('M', strtotime($datetime_string));
$day = $datetime_object->format("d");
?>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</div><!-- #row -->
</div><!-- #container -->
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.