简体   繁体   English

Symfony2,DateTime格式与日期和时间一起

[英]Symfony2, DateTime formatting with date and time together

I have created a field for publish date (with time), but I found only date formating. 我已经创建了一个用于发布日期(带有时间)的字段,但是我发现只有日期格式。 My time field is under my date field and it looks strange (for me), like this: 我的时间字段在日期字段下,对我来说看起来很奇怪,像这样:

[DAY] [MONTH] [YEAR]
[HOURS]:[MINUTES]

How can i format it like this? 我该如何格式化?

[DAY] [MONTH] [YEAR] - [HOURS]:[MINUTES]

There it is, what I now have in my Form builder: 现在,我的“表单”构建器中有了:

$builder->add('published', 'datetime', array('label' => 'Date of publish', 'date_format' => 'ddMMMMyyyy', 'empty_value' => array('year' => 'Year', 'month' => 'Month', 'day' => 'Day'), 'invalid_message' => 'Date is not valid',))

PS: I'm using selection. PS:我正在使用选择。

I have had the same problem once and solved it using the answer of this question : 我曾经遇到过同样的问题,并使用以下问题答案解决了它:

Also, find more info on the matter by browsing the following section of the Symfony2 official documentation . 另外,通过浏览Symfony2官方文档以下部分 ,找到有关此问题的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM