Issue Bug Closed

#30931date() expects parameter 2 to be long, string given in class.tslib_content.php

Simon Schaufelberger 10/14/11, 14:52 updated 10/02/18, 12:19

Description

I have the following typoscript (part of a sql string)

20 = TEXT
20.date = U
20.noTrimWrap = | AND date > ||

and i get the following warning message:

Warning: date() expects parameter 2 to be long, string given in /typo3/sysext/cms/tslib/class.tslib_content.php on line 2529

content should NEVER be a string by default here, it as written in the php docs:

string gmdate ( string $format [, int $timestamp = time() ] )

it shold be an int.

public function stdWrap_date($content = '', $conf = array()) {
    $content = ($conf['date.']['GMT'] ? gmdate($conf['date'], $content) : date($conf['date'], $content));
    return $content;
}

for me the code should be something like:

public function stdWrap_date($content = '', $conf = array()) {
    if ($content !== '') {
        $content = ($conf['date.']['GMT'] ? gmdate($conf['date'], $content) : date($conf['date'], $content));
    } else {
        $content = ($conf['date.']['GMT'] ? gmdate($conf['date']) : date($conf['date']));
    }
    return $content;
}

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.