2
=======================
8
Returns the current date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numeric context. ::
18
Returns the current time as a value in 'HH:MM:SS' or HHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone. ::
31
CURRENT_TIMESTAMP() is a synonym for NOW().
38
LOCALTIME() is a synonym for NOW().
45
LOCALTIMESTAMP() is a synonym for NOW().
52
NOW returns the current date and time. The return value will be expressed as 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS.uuuuuu, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone. ::
55
-> '2011-02-15 13:40:06'
57
-> 20110215134006.000000
59
NOW returns a constant time that indicates the time at which the statement began to execute.
63
SELECT NOW(), SLEEP(2), NOW();
67
+---------------------+----------+---------------------+
68
| NOW() | SLEEP(2) | NOW() |
69
+---------------------+----------+---------------------+
70
| 2011-02-20 20:15:09 | 0 | 2011-02-20 20:15:09 |
71
+---------------------+----------+---------------------+
73
SYSDATE, however, returns the exact time at which the function was invoked.
77
SELECT SYSDATE(), SLEEP(2), SYSDATE();
81
+---------------------+----------+---------------------+
82
| SYSDATE() | SLEEP(2) | SYSDATE() |
83
+---------------------+----------+---------------------+
84
| 2011-02-20 20:15:09 | 0 | 2011-02-20 20:15:11 |
85
+---------------------+----------+---------------------+
87
When using replication, the binary log will include SET TIMESTAMP entries so that a database can be restored from the binary log. In doing this, values from NOW will be adjusted to the same times as when the original SQL statements were executed. SYSDATE entries will be unaffected by SET TIMESTAMP entries.