[FLOW3-general] DateTime format in my view
Sergio
naguib.mahfuz at gmail.com
Wed Jan 2 18:25:58 CET 2013
Hi John,
I think you misunderstood me: I know you can change that format every time
you create an object containing a DateTime property. But I don't mean when
CREATING or UPDATING the object, but showing the form to edit before
updating. I don't know why the format of the date, despite it is saved as
"H:i" in the database, when showing, it is shown again in the default
format for my form input. If I var_dump() my object, the property shows
like this again:
*protected* 'date' =>
*object*(*DateTime*)[*1933*]
*public* 'date' => string '2013-01-02 18:18:51' *(length=19)*
*public* 'timezone_type' => int 3
*public* 'timezone' => string 'Europe/Berlin' *(length=13)
*
I would like the 'date' would show only "18:18".
Sergio
2012/12/28 John Small <flow3.tiny69 at net-con.net>
> Hi,
>
> theres a Viewhelper for that:
>
> {some.date -> f:format.date(format:'d.m.Y H:i')}
>
> but then you need to have a proper method in the controller who is able to
> handle that format of the date to pass it to the model,
> because the model expects "2012-12-28 12:33:00"
>
> like this
>
> public function initializeCreateAction() {
>
> $this->addFlashMessage('here: initializeCreateAction');
> // set Format for property begin
> $this->arguments['newEvent']
> ->**getPropertyMappingConfiguratio**n()
> ->forProperty('begin')
> ->setTypeConverterOption('**TYPO3\FLOW3\Property\**TypeConverter\**DateTimeConverter',
>
> \TYPO3\FLOW3\Property\**TypeConverter\**DateTimeConverter::**CONFIGURATION_DATE_FORMAT,
>
> '!d.m.Y H:i');
> }
>
>
> same for an update method
>
> HTH
>
>
>
> Am 28.12.2012 15:06, schrieb Sergio:
>
> Hi list,
>>
>> I have this in my edit view:
>>
>> ...
>> <f:form.textfield property="break.date" id="break" />
>> ...
>>
>> where "break" is a \DateTime property. Despite I define the break
>> attribute
>> in my model like this:
>>
>> /**
>> * The break time
>> * @var \DateTime
>> * @Flow\Validate(type="NotEmpty"**)
>> * @ORM\Column(type="time")
>> */
>> protected $break;
>>
>> and it is saved in format "12:33" in my database (because I asked for it
>> when creating through Property Mapping Configuration), when the object is
>> edited, it is shown again in format "2012-12-28 12:33:00".
>>
>> Why does this happen? And would you know a way to alter this break.date
>> format and showin "12:33" format to the user in the view?
>>
>> Thanks in advance,
>> Sergio
>>
>>
>
> --
> kind regards
>
>
> ______________________________**_________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/flow3-**general<http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general>
>
More information about the FLOW3-general
mailing list