[TYPO3-dev] how to insert date. incorrect coding or incorrect sql format?
Andrew Davis
andrew at avagraphique.com
Tue Apr 24 18:36:31 CEST 2007
Using
$transaction_date = date(U);
gives a unix timestamp and that seems to be what typo is expecting...
Andrew Davis wrote:
> Hi,
>
> Trying to insert a date into an extension table...
>
> Here is the relevant part of the sql for the table, generated by
> kickstarter
>
>
>
> CREATE TABLE tx_tablename (
> [ ... ]
> transdate int(11) DEFAULT '0' NOT NULL,
> [ ... ]
> }
>
>
>
> Here is the php from the extension that performs the insert... seems to
> work except for a couple of issues, one being date...
>
>
> $transaction_date = "12/1/2007"; //date("m/d/y");
>
> $fields_values = array (
> [ ...]
> "transdate" => $transaction_date,
> [ ... ]
> );
>
> $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery( $table, $fields_values );
>
>
>
> I tried the date() function (commented out), and then hardcoded a date
> thinking that perhaps the function not working as expected.
>
> When the record inserts, the date defaults to 12-31-1969.
>
>
>
> Any ideas??
>
> Any help much appreciated, thanks.
>
>
> Andrew
More information about the TYPO3-dev
mailing list