Hello,
for a wordpress website I was asked to create a rather complicated date sequence for events.
Using a costum field for start date and another one for end date.
I manage to get this working, however, the wordpress site is in Dutch (NL), and everywhere on the site the months are in the Dutch language, as is set in wordpress itself.
However the below function states the months in English, and for the life of me I can’t get it right.
Anybody on here who can lend me a hand please ? thanks in advance.
<?php setlocale(LC_ALL, 'nl_NL');
$start_date = get_field('datum', false, false);
$start_date = new DateTime($start_date);
$end_date = get_field('eind_datum', false, false);
$end_date = new DateTime($end_date);
$start_month = $start_date->format('F');
$end_month = $end_date->format('F');
?>
<?php if ( get_field('eind_datum') and get_field('datum') ): ?>
<span class='datum'>
<?php
if ($start_month == $end_month) {
// output July 12-13, 2020
echo $start_date->format ('j'); ?>-<?php echo $end_date->format ('j F Y');
} else {
// output July 12 - August 3, 2020
echo $start_date->format('j F'); ?>-<?php echo $end_date->format ('j F Y');
}
?>
</span>
<?php elseif ( empty(get_field('eind_datum')) and (empty(get_field('datum')) === false)): ?>
<span class='datum'><?php echo the_field('datum'); ?></span>
<?php endif; ?>