CURRENT_TIMESTAMP()

Description

CURRENT_TIMESTAMP and CURRENT_TIMESTAMP() are synonyms for NOW().

Returns the current date and time as a value in YYYY-MM-DD hh:mm:ss or YYYYMMDDhhmmss format, depending on whether the function is used in string or numeric context. The value is expressed in the session time zone.

Syntax

  1. > CURRENT_TIMESTAMP([fsp])

Arguments

ArgumentsDescription
fspOptional. If the fsp argument is given to specify a fractional seconds precision from 0 to 6, the return value includes a fractional seconds part of that many digits.

Examples

  1. mysql> SELECT CURRENT_TIMESTAMP();
  2. +----------------------------+
  3. | current_timestamp() |
  4. +----------------------------+
  5. | 2022-09-21 11:46:44.153777 |
  6. +----------------------------+
  7. 1 row in set (0.00 sec)
  8. mysql> SELECT NOW();
  9. +----------------------------+
  10. | now() |
  11. +----------------------------+
  12. | 2022-09-21 12:56:36.915961 |
  13. +----------------------------+
  14. 1 row in set (0.01 sec)
  1. create table t1 (a int primary key, b int, c int, d timestamp default current_timestamp);
  2. insert into t1 select 1,1,1,now();
  3. insert into t1 select 2,0,0,null;
  4. mysql> select a,b,c,year(d) from t1;
  5. +------+------+------+---------+
  6. | a | b | c | year(d) |
  7. +------+------+------+---------+
  8. | 1 | 1 | 1 | 2022 |
  9. | 2 | 0 | 0 | NULL |
  10. +------+------+------+---------+
  11. 2 rows in set (0.01 sec)

Constraints

Operator + or - is not supported for using with CURRENT_TIMESTAMP now.