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
| Arguments | Description |
|---|---|
| fsp | Optional. 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)
9. mysql> SELECT NOW();
10. +----------------------------+
11. | now() |
12. +----------------------------+
13. | 2022-09-21 12:56:36.915961 |
14. +----------------------------+
15. 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;
5. mysql> select a,b,c,year(d) from t1;
6. +------+------+------+---------+
7. | a | b | c | year(d) |
8. +------+------+------+---------+
9. | 1 | 1 | 1 | 2022 |
10. | 2 | 0 | 0 | NULL |
11. +------+------+------+---------+
12. 2 rows in set (0.01 sec)
Constraints
Operator + or - is not supported for using with CURRENT_TIMESTAMP now.
