DateTimePicker: support *nix timestamps

refs #2749
This commit is contained in:
Alexander A. Klimov 2017-02-13 18:20:22 +01:00 committed by Eric Lippmann
parent a444b8adf5
commit 880a0a254f
1 changed files with 5 additions and 0 deletions

View File

@ -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;
}