MariaDB CURRENT_TIMESTAMP() Function

In MariaDB, CURRENT_TIMESTAMP() is a built-in function that returns the current date and time.

CURRENT_TIMESTAMP() is a synonym for NOW().

MariaDB CURRENT_TIMESTAMP() Syntax

This is the syntax of the MariaDB CURRENT_TIMESTAMP() function:

CURRENT_TIMESTAMP
CURRENT_TIMESTAMP([precision])

Parameters

precision

Optional. The precision of fractional seconds. From 1 to 6.

Return value

MariaDB CURRENT_TIMESTAMP() returns the current date and time.

CURRENT_TIMESTAMP() returns the current date and time in the YYYY-MM-DD HH:MM:SS format in a string context and returns the current date and time in YYYYMMDDHHMMSS.uuuuuu format in a numeric context.

MariaDB CURRENT_TIMESTAMP() Examples

Example 1

The following statement shows the basic usage of the MariaDB CURRENT_TIMESTAMP() function:

SELECT
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP(),
    CURRENT_TIMESTAMP(3),
    CURRENT_TIMESTAMP(6)\G

Output:

   CURRENT_TIMESTAMP: 2023-01-06 02:13:50
 CURRENT_TIMESTAMP(): 2023-01-06 02:13:50
CURRENT_TIMESTAMP(3): 2023-01-06 02:13:50.248
CURRENT_TIMESTAMP(6): 2023-01-06 02:13:50.248662

Example 2 - Numeric Context

If in a numeric context, the resulting datetime is in the YYYYMMDDHHMMSS.uuuuuu format.

SELECT
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP + 0,
    CURRENT_TIMESTAMP(6) + 0\G

Output:

       CURRENT_TIMESTAMP: 2023-01-06 02:14:35
   CURRENT_TIMESTAMP + 0: 20230106021435
CURRENT_TIMESTAMP(6) + 0: 20230106021435.028334

Conclusion

In MariaDB, CURRENT_TIMESTAMP() is a built-in function that returns the current datetime.