From c2014a7f66b26135b79ac24f08e7bf31995bd7c7 Mon Sep 17 00:00:00 2001 From: Alexander Walther Date: Sun, 1 Sep 2024 22:56:04 +0200 Subject: [PATCH] Update datestamp.php --- lib/yform/value/datestamp.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/yform/value/datestamp.php b/lib/yform/value/datestamp.php index 4358b8893..b042f0ce9 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); + } } }