Name
CURRENT_TIMESTAMP()
Synopsis
CURRENT_TIMESTAMP()
This function returns the current date and time in
yyyy-mm-dd hh:mm:ss
format. It will return
the time in a yyyymmddhhmmss
format
(numeric format) if it’s used as part of a numeric calculation.
Parentheses aren’t required. It’s a synonym of NOW(). Here is an example:
SELECT CURRENT_TIMESTAMP() AS Now, CURRENT_TIMESTAMP() + 10000 AS 'Hour Later'; r'; +---------------------+----------------+ | Now | Hour Later | +---------------------+----------------+ | 2008-01-12 16:41:47 | 20080112174147 | +---------------------+----------------+
By adding 10,000 to the current time, the hour is increased by 1
and the minutes and seconds by 0 each, and the time is displayed in
the second field without dashes. This is in line with the
yyyymmddhhmmss
format involved in numeric
calculations, with the numbers
right-justified.
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.