[TYPO3-mvc] [Extbase] Get tstamp / crdate right after persist

Claus Fassing claus at fassing.eu
Tue Jun 4 09:43:23 CEST 2013


Am 03.06.2013 18:28, schrieb Christian Müller:
>
> On 03.06.13 17:58, Xavier Perseguers wrote:
>> >Hi,
>> >
>> >Patrick Schriner wrote:
>>> >>Hi,
>>> >>
>>> >>I guess you are right - these properties are not set correctly:
>>> >>
>>> >>http://api.typo3.org/typo3cms/45/html/class_tx___extbase___persistence___backend.html#af0f9e5de728278d6cc3e1e000c8667e7
>>> >>
>>> >>
>>> >>Only the "uid" is refreshed immediately.
>>> >>
>>> >>I once had a similar problem and could not find a way to force-refresh
>>> >>that tstamp or crdate.
>>> >>
>>> >>The best thing you can do is to redirect to a different action passing
>>> >>the new object as an argument - as this will trigger a new mapping (from
>>> >>the database) the tstamp and crdate will be correct.
>> >
>> >That's the "clean" way but I would simply go for using
>> >$GLOBALS['EXEC_TIME'] (timestamp) or the corresponding DateTime(...)
>> >value because internally the date is nothing magic and is set to this
>> >value anyway.
> It should also work to set the properties in the constructor, the you
> can immediately access the values.

Thank you very much to all of you for the helpful answers.

It's a bit cute.

I use the $GLOBALS['EXEC_TIME'] to set the tstamp at runtime and the 
timestamp is equal to database field.
But I already attempted before to set the tstamp with
$dateTime = new DateTime('now', new DateTimeZone('Europe/Berlin'));
$newData->setTstamp($dateTime->format('U'));
and the result differs from database field.
e.g.
new DateTime... = 1370329766
DB = 1370329764
(Doesn't matter if I use type DateTime or integer)

For this I set the field config type in TCA to passthrough.
'tstamp' => Array(
     'exclude' => 0,
     'label' => 'Change date',
     'config' => Array(
	'type' => 'passthrough',
     )
),

Looks like that I'm not able to set the tstamp at runtime, but the time 
I need for further processing can I get from $GLOBALS['EXEC_TIME']. This 
helps anyway.

Thank you,

Claus



More information about the TYPO3-project-typo3v4mvc mailing list