使用 MySQL 获取时间戳

2022-01-13 00:00:00 timestamp mysql

如何使用 mysql 查询获取当前时间戳?

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

推荐答案

取决于您要寻找的类型.

Depends on which kind you're looking for.

当前整数 Unix 时间戳 (1350517005) 可以这样检索:

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

SELECT UNIX_TIMESTAMP();

MySQL 通常将时间戳显示为日期/时间字符串.要获得其中之一,这些是您的基本选项(来自 MySQL 日期和时间参考):

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();

相关文章