MySQL LOCALTIMESTAMP() Function
In MySQL, the LOCALTIMESTAMP()
function returns the current date and time in the YYYY-MM-DD hh:mm:ss
or YYYYMMDDhhmmss
format.
This function is exactly the same as the NOW()
function.
LOCALTIMESTAMP()
Syntax
Here is the syntax of MySQL LOCALTIMESTAMP()
function:
LOCALTIMESTAMP
LOCALTIMESTAMP()
LOCALTIMESTAMP()
Examples
Returns the current time of the system.
SELECT LOCALTIMESTAMP(), LOCALTIMESTAMP() + 1;
+---------------------+-------------------------+
| LOCALTIMESTAMP() | LOCALTIMESTAMP() + 1 |
+---------------------+-------------------------+
| 2022-04-12 02:29:32 | 20220412022933 |
+---------------------+-------------------------+
Here, the context of LOCALTIMESTAMP()
is a mathematical operation within LOCALTIMESTAMP() + 1
, so LOCALTIMESTAMP()
returns a number in YYYYMMDDhhmmss
format.