MySQL LOCALTIMESTAMP() Function

The LOCALTIMESTAMP() function returns the current date and time based on the system's local timezone.


Definition and Usage

  • The LOCALTIMESTAMP() function returns the current date and time in the local timezone, formatted as "YYYY-MM-DD HH:MM:SS".

Syntax

LOCALTIMESTAMP()
  • No parameters are required for this function.

Examples

Example 1: Return current date and time

SELECT LOCALTIMESTAMP();

Output:

2024-12-28 13:15:35

This example returns the current local date and time.

Example 2: Return current date and time + 1 (adding 1 second)

SELECT LOCALTIMESTAMP() + 1;

Output:

2024-12-28 13:15:36

This adds 1 second to the current local date and time.


Technical Details

  • Works in MySQL versions: From MySQL 4.0.
  • Return type: The function returns a DATETIME value representing the current local time.

Was this article helpful?