如何使用 PHP 将 MySQL 时间转换为 UNIX 时间戳?

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

有很多关于UNIX 时间戳到 MySQL 时间"的问题.我需要相反的方式,是的...有什么想法吗?

There are a lot of questions that ask about 'UNIX timestamp to MySQL time'. I needed the reversed way, yea... Any idea?

推荐答案

使用strtotime(..):

$timestamp = strtotime($mysqltime);
echo date("Y-m-d H:i:s", $timestamp);

也检查一下(以 MySQL 方式进行.)

Also check this out (to do it in MySQL way.)

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp

相关文章