Skip to main content

Auslesen Datenbank mit Datum

class Order  {
    public int $id;
    public int $user_id;
    public DateTime $dateTime; // bewusst anders als Spalte nennen!
    public float $amount;
    public string $street;
    public string $postcode;
    public string $city;

    // DateTime muss manuell umgewandelt werden!
    public function __set($property, $value){
        if($property === 'name'){
            $this->dateTime = DateTime::createFromFormat('Y-m-d H:i:s', $value);
        } else {
            $this->$property = $value;
        }
    }
}