From 880a0a254f5b7bfd177049056e5ce8d8feb616c9 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 13 Feb 2017 18:20:22 +0100 Subject: [PATCH] DateTimePicker: support *nix timestamps refs #2749 --- library/Icinga/Web/Form/Element/DateTimePicker.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Icinga/Web/Form/Element/DateTimePicker.php b/library/Icinga/Web/Form/Element/DateTimePicker.php index 274c3b676..284a744e3 100644 --- a/library/Icinga/Web/Form/Element/DateTimePicker.php +++ b/library/Icinga/Web/Form/Element/DateTimePicker.php @@ -56,6 +56,11 @@ class DateTimePicker extends FormElement */ public function isValid($value, $context = null) { + if (is_scalar($value) && $value !== '' && ! preg_match('/\D/', $value)) { + $dateTime = new DateTime(); + $value = $dateTime->setTimestamp($value)->format($this->getFormat()); + } + if (! parent::isValid($value, $context)) { return false; }