From cea1f619b30f566ec09886cac7c3ad1564290310 Mon Sep 17 00:00:00 2001 From: Martin Bean Date: Fri, 6 Nov 2015 13:44:42 +0000 Subject: [PATCH] Add datetime input types --- src/FormBuilder.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/FormBuilder.php b/src/FormBuilder.php index 69f48088..5f2e35e3 100755 --- a/src/FormBuilder.php +++ b/src/FormBuilder.php @@ -359,6 +359,42 @@ public function date($name, $value = null, $options = []) return $this->input('date', $name, $value, $options); } + /** + * Create a datetime input field. + * + * @param string $name + * @param string $value + * @param array $options + * + * @return string + */ + public function datetime($name, $value = null, $options = []) + { + if ($value instanceof DateTime) { + $value = $value->format(DateTime::RFC3339); + } + + return $this->input('datetime', $name, $value, $options); + } + + /** + * Create a datetime-local input field. + * + * @param string $name + * @param string $value + * @param array $options + * + * @return string + */ + public function datetimeLocal($name, $value = null, $options = []) + { + if ($value instanceof DateTime) { + $value = $value->format('Y-m-d\TH:i'); + } + + return $this->input('datetime-local', $name, $value, $options); + } + /** * Create a time input field. *