MariaDB NOW() Function

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

The NOW() function is exactly the same as LOCALTIME(), LOCALTIMESTAMP() and CURRENT_TIMESTAMP().

MariaDB NOW() Syntax

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

NOW([precision])

Parameters

precision

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

Return value

MariaDB NOW() returns the current datetime.

If in a string context, NOW() returns the current date in the YYYY-MM-DD HH:MM:SSformat and it returns the current date and time in YYYYMMDDHHMMSS.uuuuuu format if in a numeric context.

MariaDB NOW() Examples

Example 1

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

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

Output:

 NOW(): 2023-01-11 11:28:40
NOW(3): 2023-01-11 11:28:40.296
NOW(6): 2023-01-11 11:28:40.296380

Example 2 - Numeric Context

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

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

Output:

     NOW(): 2023-01-11 11:29:02
 NOW() + 0: 20230111112902
NOW(6) + 0: 20230111112902.292928

Conclusion

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