The timestamp data type stores the time that a row was last changed : timestamp « Data Types « MySQL Tutorial






TIMESTAMP column will be set to the current date and time whenever that row is updated or inserted in the table.

TIMESTAMP can only handle dates in the range 1970 through 2037.

TIMESTAMP data can be held with the maximum resolution of one second.

TIMESTAMP can have a number of external formats.

These can be made up of any even number of digits from 2 to 14.

TIMESTAMP fields are set to the current time if you do not write anything to them.

MySQL sets a TIMESTAMP column to the current time if NULL (or NOW()) is written to it.

Illegal values will be discarded and replaced with the "zero" value for this field type.

MySQL is flexible in the formats accepting for the TIMESTAMP.

For example, it will accept 2000-05-12, 2000+05+12, and 20000512.

If the field is left out when doing an insert or update, it will only update the first TIMESTAMP field in the table.

Subsequent TIMESTAMP fields will contain the zero value if not set explicitly.

If you have a DATE value and want to write it to a DATETIME or TIMESTAMP column, MySQL will insert 00:00:00 for the time portion.

The format varies according to the length.

For example to store the same information as DATETIME, you would specify a length of 14 whereas to store the DATE you would specify a length of 8.

Timestamp DefinitionFormat
TIMESTAMP(2)YY
TIMESTAMP(4)YYYY
TIMESTAMP(6)YYMMDD
TIMESTAMP(8)YYYYMMDD
TIMESTAMP(10)YYMMDDHHMM
TIMESTAMP(12)YYMMDDHHMMSS
TIMESTAMP(14)YYYYMMDDHHMMSS










10.24.timestamp
10.24.1.The timestamp data type stores the time that a row was last changed
10.24.2.TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00'
10.24.3.TIMESTAMP NULL DEFAULT NULL
10.24.4.You can include the NULL attribute in the definition of a TIMESTAMP column to allow the column to contain NULL values. For example:
10.24.5.mysql> SELECT MICROSECOND('2010-12-10 14:12:09.019473');
10.24.6.TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP