diff --git a/lib/yform/value/datestamp.php b/lib/yform/value/datestamp.php index 4358b889..b042f0ce 100644 --- a/lib/yform/value/datestamp.php +++ b/lib/yform/value/datestamp.php @@ -16,8 +16,12 @@ public function preValidateAction(): void $default_value = date(rex_sql::FORMAT_DATETIME); if ('' != $this->getElement('modify_default')) { $dt = new DateTime(); - if (false !== @$dt->modify($this->getElement('modify_default'))) { - $default_value = $dt->format(rex_sql::FORMAT_DATETIME); + // Überprüfen, ob der Zeitstring ein gültiges Datum/Zeit-Format hat + $test_dt = DateTime::createFromFormat('Y-m-d H:i:s', $modify_default); + if ($test_dt && $test_dt->format('Y-m-d H:i:s') === $modify_default) { + if (false !== @$dt->modify($modify_default)) { + $default_value = $dt->format(rex_sql::FORMAT_DATETIME); + } } }