Return the current date and time. This function returns the current timestamp as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format.
Returns the current date and time as a value in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context. The value is expressed in the current .
MariaDB starting with
These functions return SQL standard compliant types:
NOW() and CURRENT_TIMESTAMP() return a TIMESTAMP value (analogous to the standard type TIMESTAMP WITH LOCAL TIME ZONE) which corresponds to the current point in time and is unambiguous around DST changes.
LOCALTIMESTAMP returns a DATETIME value (analogous to the standard type
The optional precision determines the microsecond precision. See .
NOW() (or its synonyms) can be used as the default value for columns as well as.
When displayed in the table, a default is displayed as current_timestamp() .
Changing the with a timestamp statement affects the value returned by NOW(), but not by .
With precision:
Used as a default TIMESTAMP:
This page is licensed: GPLv2, originally from
NOW([precision])
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP([precision])
LOCALTIME, LOCALTIME([precision])
LOCALTIMESTAMP
LOCALTIMESTAMP([precision])TIMESTAMP WITHOUT TIME ZONETIMESTAMPThese functions do not return SQL standard compliant types:
NOW()
CURRENT_TIMESTAMP()
LOCALTIMESTAMP
SELECT NOW();
+---------------------+
| NOW() |
+---------------------+
| 2010-03-27 13:13:25 |
+---------------------+
SELECT NOW() + 0;
+-----------------------+
| NOW() + 0 |
+-----------------------+
| 20100327131329.000000 |
+-----------------------+SELECT CURRENT_TIMESTAMP(2);
+------------------------+
| CURRENT_TIMESTAMP(2) |
+------------------------+
| 2018-07-10 09:47:26.24 |
+------------------------+CREATE TABLE t (createdTS TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP);SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='test'
AND COLUMN_NAME LIKE '%ts%'\G
*************************** 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: test
TABLE_NAME: t
COLUMN_NAME: ts
ORDINAL_POSITION: 1
COLUMN_DEFAULT: current_timestamp()
...