All pages
Powered by GitBook
1 of 1

Loading...

NOW

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.

Syntax

Description

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 .

Examples

With precision:

Used as a default TIMESTAMP:

See Also

This page is licensed: GPLv2, originally from

NOW([precision])
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP([precision])
LOCALTIME, LOCALTIME([precision])
LOCALTIMESTAMP
LOCALTIMESTAMP([precision])
TIMESTAMP WITHOUT TIME ZONE
). Storing its result in a
TIMESTAMP
column can result in a data loss around DST changes.

These functions do not return SQL standard compliant types:

  • NOW()

  • CURRENT_TIMESTAMP()

  • LOCALTIMESTAMP

time zone
Microseconds in MariaDB
TIMESTAMP
INFORMATION_SCHEMA.COLUMNS
CURRENT TIMESTAMP
timestamp system variable
SET
SYSDATE()
Microseconds in MariaDB
timestamp server system variable
fill_help_tables.sql
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()
...
11.7