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

Xavier Perseguers xavier at typo3.org
Tue Jun 4 10:00:57 CEST 2013


Hi,

> 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)

The difference is 1370329766 - 1370329764 = 2 seconds which is +/-
related to the time Extbase takes to process your request.
$GLOBALS['EXEC_TIME'] is set once at the beginning of the request by
TYPO3 Core and then is used through the code, even if when the record is
actually written to the DB some seconds have passed, meaning

$dateTime = new DateTime('now')

gives you the real value but

$dateTime = new DateTime('@' . $GLOBALS['EXEC_TIME']);

(or whatever way you use to reuse a timestamp)

will give you what's actually used in DB.

Hope this shed some light on the internals of TYPO3.

Kind regards

-- 
Xavier Perseguers
Release Manager TYPO3 4.6

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org



More information about the TYPO3-project-typo3v4mvc mailing list