[英]Symfony2 datetime field form
I have a Symfony2 application which receive a JSON data in a form. 我有一个Symfony2应用程序,该应用程序以形式接收JSON数据。 One of the field is a date time.
字段之一是日期时间。 If I renderize the field form in this way:
如果我以这种方式渲染字段表单:
->add('startDate', 'date', array(
'widget' => 'single_text',
'format' => 'yyyy-MM-dd HH:mm:ss'))
This accept something like: 这接受类似:
"startDate": "2015-05-03 12:30:00"
But I need to introduce a datetime in this way: 但是我需要以这种方式介绍日期时间:
"startDate": "2015-05-12T15:43:00+0200"
How can I set this format in the field? 如何在现场设置这种格式?
On http://php.net/manual/en/function.date.php 在http://php.net/manual/en/function.date.php
"c" => ISO 8601 date (added in PHP 5) => 2004-02-12T15:19:21+00:00 “ c” => ISO 8601日期(PHP 5中添加) => 2004-02-12T15:19:21 + 00:00
Try this: 尝试这个:
->add('startDate', 'date', array(
'widget' => 'single_text',
'format' => 'c'))
I hope it helps. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.