Hi,
I stored a date in an ACF Date Picker field as follows: 12-06-2016 (DD-MM-YYYY). In the front-end I want to return it like TUE 21 06, but translated? Should be Di 21 06.
. This
<?php $date = get_field('datum', false, false); $date = new DateTime($date);echo $date->format('D d M'); ?>
… Returns TUE 21 6 and is exactly what I wanted. Only thing is, this isn’t in Dutch, but how do I use the translation without messing up the date format? The ‘translations’ code mentioned here didn’t work for me as it returned only incorrect dates. https://www.advancedcustomfields.com/resources/date-picker/
Hi @avwijk
Could you please try the following code?
$date = get_field('datum', false, false);
$date = new DateTime($date);
$dateformatstring = 'D d M';
$unixtimestamp = $date->getTimestamp();
echo date_i18n($dateformatstring, $unixtimestamp);
Thanks 🙂