Skip to content

Commit

Permalink
Add datetime input types
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbean committed Nov 6, 2015
1 parent a4acc4a commit cea1f61
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit cea1f61

Please sign in to comment.