[TYPO3-dev] bug dbType for date before 01-01-1970

Jigal van Hemert jigal.van.hemert at typo3.org
Thu Sep 25 14:18:32 CEST 2014


Hi Xavier,

On 25-9-2014 10:13, Xavier Perseguers wrote:
> It does not work properly since you cannot do anything useful with pure
> MySQL queries on negative timestamp.

"anything" is a big word here :-) You have to use some tricks, but if 
you *have* to work with negative timestamps in MySQL you can use:

DATE_ADD(FROM_UNIXTIME(0), INTERVAL date_of_birth SECOND)

FROM_UNIXTIME(date_of_birth) returns NULL for negative timestamps.

The original definition of the Unix timestamp stated that timestamps for 
dates prior to 1-1-1970 were "undefined". The C library for date / time 
calculations however supported negative timestamps until quite a few 
years ago one of the developers found the original definition and 
removed the support. PHP quickly added support (because it broke a lot 
of scripts around the world) but apparently MySQL sticks to the original 
definition (or just uses the C library).

-- 
Jigal van Hemert
TYPO3 CMS Active Contributor

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



More information about the TYPO3-dev mailing list