[Gelöst] PHP MariaDB und UTC

  • Nach dem setzen von default-time-zone=+00:00 in /etc/mysql/mariadb.conf.d/50-server.cnf zeigt mein PHP-Script die Uhrzeit aus der Datenbank natürlich auch als UTC, statt die lokale Zeit.

    Das zeigt die Uhrzeit richtig an:

    PHP
    <?php
    date_default_timezone_set("Europe/Berlin");
    $timestamp = time();
    $datum = date("d.m.Y", $timestamp);
    $uhrzeit = date("H:i:s",$timestamp);
    echo "Aktuelles Datum und Zeit : ";
    echo $datum," - ",$uhrzeit," Uhr<br />\n";
    ?>

    Aber wie muss ich dieses Script umschreiben, damit ich wieder die lokale Zeit angezeigt bekomme ?

    Gibt es da eine einfache Lösung für ?

    :helpnew:

    Edit: So funktioniert es:

  • fred0815 June 5, 2025 at 9:43 AM

    Changed the title of the thread from “PHP MariaDB und UTC” to “[Gelöst] PHP MariaDB und UTC”.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!