bUTschy.de

  • code

IntlDateFormatter

Das Datum in der Datenbank liegt im Format 2023-03-19 07:18:22 vor.

Ein Code soll das Datum jetzt ohne Verwendung von setlocale so umwandeln, das es komplett in Deutsch zu so einer Ausgabe kommt.

Am Sonntag, den 19. März 2023 um 07:18 Uhr

$datenbankdatum = '2023-03-19 07:18:22';
$datum = new DateTime($datenbankdatum);
$dateform = new 
IntlDateFormatter('de_DE.UTF-8', 
IntlDateFormatter::LONG, 
IntlDateFormatter::MEDIUM, 'Europe/Berlin', 
IntlDateFormatter::GREGORIAN, " 
'Am' EEEE', den' dd. MMMM YYYY 'um' HH:mm 'Uhr'");

Ausgabe:

/* Am Sonntag, den 19. März 2023 um 07:18 Uhr */
echo $dateform->format($datum);
  • 0 Kommentare
  • 374 Klicks

▼ Kommentare


Kommentar hinzufügen