Lesson

MySQL CURRENT_TIMESTAMP() Function

10 min reading
Free Course

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 between 0 and 6 controlling 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 NULL crashes: CURRENT_TIMESTAMP() requires no external input, so NULL values in queried columns never make it return NULL.
  • Constant across the statement: Like NOW(), CURRENT_TIMESTAMP returns when the statement began executing, not the live wall clock during a slow multi-row update.
  • Invalid fsp throws an error: Only integer literals 0 through 6 are valid; CURRENT_TIMESTAMP(NULL) or CURRENT_TIMESTAMP(8) causes a syntax error.
  • Precision mismatch on DEFAULT: When setting DEFAULT CURRENT_TIMESTAMP(6) on a column, the column itself must also be declared as DATETIME(6) or TIMESTAMP(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.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Try it Yourself

Experiment with the code from this lesson in our interactive playground.

Open Playground
MySQL Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum