pedro mpa wrote:
> Greetings!
>
> I am building a website using MySQL 5.0.18 and PHP 5.1.2.
> When I try to insert in a table a timestamp value from php's mktime() I get
> the following error:
> 1292: Incorrect datetime value: '1139776424' for column 'access_date' at row
> 1
>
> The sql for the table is:
> CREATE TABLE `members_acs` (
> `id` int(17) unsigned NOT NULL auto_increment,
> `member_id ` int(13) unsigned default NULL,
> `access_date` timestamp NOT NULL default '0000-00-00 00:00:00',
> `ip` varchar(15) default NULL,
> PRIMARY KEY (`id`),
> UNIQUE KEY `id` (`id`)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1
>
> Are timestamps different from php to mysql?
>
> When I first create a timestamp field it defaults to CURRENT_TIMESTAMP then
> the following will default to 0000-00-00 00:00:00 . Is this the normal
> behaviour? What am I doing wrong?
>
> Thanks in advance.
>
> Pedr.
The mysql TIMESTAMP is not a unix timestamp, so it isn't compatible with the
output of php's mktime(). See the manual for the details of the TIMESTAMP type:
<http://dev.mysql.com/doc/refman/5.0/en/date-and-time-type-overview.html>
<http://dev.mysql.com/doc/refman/5.0/en/date-and-time-types.html>
<http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html>
<http://dev.mysql.com/doc/refman/5.0/en/datetime.html>
Michael
| Thread |
|---|
| • Timestamp error | pedro mpa | 12 Feb |
| • Re: Timestamp error | Michael Stassen | 13 Feb |