Lkopo
Lkopo

Reputation: 4835

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.

Upvotes: 0

Views: 4387

Answers (1)

Udan
Udan

Reputation: 5609

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.

Upvotes: 1

Related Questions