Last active
April 8, 2021 06:08
-
-
Save ivo-ivanov/c571dff0edb069b1048c9c4988259ad0 to your computer and use it in GitHub Desktop.
Output ACF Date Field in german date format. #php #acf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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