This tutorial explains how to use the MySQL TIMESTAMP function with syntax and examples.
The MySQL TIMESTAMP function converts an expression to a datetime value and if specified adds an optional time interval to the value.
The syntax for the TIMESTAMP function in MySQL is:
TIMESTAMP( expression, [ interval ] )
A date or datetime value that will be converted.
Optional. It is a time value to add to the expression.
The TIMESTAMP function can be used in the following versions of MySQL:
Let's look at some MySQL TIMESTAMP function examples and explore how to use the TIMESTAMP function in MySQL.
For example:
mysql> SELECT TIMESTAMP('2014-02-18');
Output: '2014-02-18 00:00:00'
mysql> SELECT TIMESTAMP('2014-02-18', '07:32:00');
Output: '2014-02-18 07:32:00'
mysql> SELECT TIMESTAMP('2014-02-18 10:05:00', '02:03:04');
Output: '2014-02-18 12:08:04'