Symfony 2表单中的日期时间字段 [英] Symfony 2 Datetime field in Forms

查看:192
本文介绍了Symfony 2表单中的日期时间字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立如下表格:

$builder->add('taskDate', 'datetime', array(
                  'required'=>false,
                  'label'=>'Termin',
                  'input'=>'datetime',
                  'widget'=>'single_text',
                  'attr'=>array('style'=>'max-width: 150px;')
              ))

我得到这个,

2014-02-01T20:00:00+01:00

如何获得正常的Datetime格式,就像我在SQL数据库中所拥有的那样?

How can I get "normal" Datetime format like what I have in my SQL database?

在我的数据库中保存如下: 2014-02-01 20:00:00

In my database it's saved as follow: 2014-02-01 20:00:00.

所以,为什么我有 T 信和 +01:00 在结尾?

So, why do I have T letter and +01:00 at the end?

推荐答案

检查 //symfony.com/doc/2.1/reference/forms/types/datetime.htmlrel =nofollow>日期时间字段类型

date_format:
type: integer or string default: IntlDateFormatter::MEDIUM
Defines the format option that will be passed down to the date field. 

请参阅日期类型的格式选项以获取更多详细信息。

See the date type's format option for more details.

这篇关于Symfony 2表单中的日期时间字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆