MySQL CURRENT_TIMESTAMP() Function
MySQL CURRENT_TIMESTAMP(): Capture Full Date and Time
CURRENT_TIMESTAMP and CURRENT_TIMESTAMP() return the current date and time as a DATETIME value in the session time zone. It is the ANSI SQL synonym for NOW() and is widely used in audit columns and event logging.
Applications use CURRENT_TIMESTAMP both inside SELECT queries and in CREATE TABLE definitions for automatic timestamps.
Syntax
You can call it without parentheses, with empty parentheses, or with fractional seconds precision:
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP()
CURRENT_TIMESTAMP(fsp)
fsp: Optional integer literal between0and6controlling microsecond digits.
String context yields 'YYYY-MM-DD HH:MM:SS[.ffffff]', while numeric context yields YYYYMMDDHHMMSS[.ffffff].
Practical Example
Suppose your support team audits recent orders in demo_orders and records the exact millisecond snapshot of the audit query.
SELECT
order_id,
customer_id,
created_at,
CURRENT_TIMESTAMP(3) AS audit_snapshot
FROM demo_orders
WHERE created_at <= CURRENT_TIMESTAMP()
ORDER BY order_id DESC
LIMIT 2;
| order_id | customer_id | created_at | audit_snapshot |
|---|---|---|---|
| 502 | 88 | 2026-05-12 09:41:12 | 2026-05-12 10:05:44.312 |
| 501 | 64 | 2026-05-12 08:19:05 | 2026-05-12 10:05:44.312 |
You can also attach DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP to a DATETIME or TIMESTAMP column to track row creation and edits automatically.
Common Mistakes & NULL Behavior
Keep these technical details in mind when using CURRENT_TIMESTAMP:
- No required arguments means no
NULLcrashes:CURRENT_TIMESTAMP()requires no external input, soNULLvalues in queried columns never make it returnNULL. - Constant across the statement: Like
NOW(),CURRENT_TIMESTAMPreturns when the statement began executing, not the live wall clock during a slow multi-row update. - Invalid
fspthrows an error: Only integer literals0through6are valid;CURRENT_TIMESTAMP(NULL)orCURRENT_TIMESTAMP(8)causes a syntax error. - Precision mismatch on
DEFAULT: When settingDEFAULT CURRENT_TIMESTAMP(6)on a column, the column itself must also be declared asDATETIME(6)orTIMESTAMP(6).
Frequently Asked Questions
Is there any difference between CURRENT_TIMESTAMP() and NOW()?
No. In MySQL, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP(), and NOW() are exact synonyms and behave identically in queries and DEFAULT clauses.
When should I use SYSDATE() instead of CURRENT_TIMESTAMP()?
Use SYSDATE() only when you need the exact clock time at the moment each row evaluates, such as benchmarking a SLEEP() call.
Why did my stored TIMESTAMP shift after changing server time_zone?
TIMESTAMP columns store values in UTC internally and convert them to @@session.time_zone on retrieval, while DATETIME columns keep the literal date and time.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Try it Yourself
Experiment with the code from this lesson in our interactive playground.