Getting timestamp using MySQL

bsytKorbi picture bsytKorbi · Dec 10, 2010 · Viewed 96.2k times · Source

How can I get the current timestamp using a mysql query?

Answer

Brad Koch picture Brad Koch · Oct 18, 2012

Depends on which kind you're looking for.

The current integer Unix Timestamp (1350517005) can be retrieved like so:

SELECT UNIX_TIMESTAMP();

MySQL often displays timestamps as date/time strings. To get one of those, these are your basic options (from the MySQL Date & Time reference):

SELECT CURRENT_TIMESTAMP;
SELECT CURRENT_TIMESTAMP();
SELECT NOW();