Mysql Localtimestamp Function

MySQL: LOCALTIMESTAMP Function

This tutorial explains how to use the MySQL LOCALTIMESTAMP function with syntax and examples.

Description

The MySQL LOCALTIMESTAMP function returns the current date and time.

Syntax

The syntax for the LOCALTIMESTAMP function in MySQL is:

LOCALTIMESTAMP( )

Parameters or Arguments

There are no parameters or arguments for the LOCALTIMESTAMP function.

Note

  • The LOCALTIMESTAMP function will return the current date as a 'YYYY-MM-DD HH:MM:SS' format, if used in a string context.
  • The LOCALTIMESTAMP function will return the current date as a YYYYMMDDHHMMSS format, if used in a numeric context in versions of MySQL prior to MySQL 4.1.13.
  • The LOCALTIMESTAMP function will return the current date as a YYYYMMDDHHMMSS.uuuuuu format, if used in a numeric context in versions of MySQL 4.1.13 and newer.
  • The LOCALTIMESTAMP, CURRENT_TIMESTAMP, and LOCALTIME functions are synonyms for the NOW function.

Applies To

The LOCALTIMESTAMP function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0.6

Example

Let's look at some MySQL LOCALTIMESTAMP function examples and explore how to use the LOCALTIMESTAMP function in MySQL.

For example:

mysql> SELECT LOCALTIMESTAMP();
Output: '2014-02-16 09:00:35'

mysql> SELECT LOCALTIMESTAMP() + 0;
Output: 20140216090035.000000

mysql> SELECT LOCALTIMESTAMP() + 1;
Output: 20140216090036.000000