Skip to content

Instantly share code, notes, and snippets.

@ivo-ivanov
Last active April 8, 2021 06:08
Show Gist options
  • Save ivo-ivanov/c571dff0edb069b1048c9c4988259ad0 to your computer and use it in GitHub Desktop.
Save ivo-ivanov/c571dff0edb069b1048c9c4988259ad0 to your computer and use it in GitHub Desktop.
Output ACF Date Field in german date format. #php #acf
<?php
// for example we start from a variable like this
$yyyymmdd = get_field('date');
// set the local time to italian
date_default_timezone_set('Europe/Zurich');
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
// convert the variable $yyyymmdd to a real date with DateTime
$truedate = DateTime::createFromFormat('Ymd', $yyyymmdd);
$datum = ucfirst(strftime('%A. %d %B %Y', $truedate->format('U')));
//Output Dienstag. 26 Januar 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment