我希望使用 将 a 转换为MySQL timestamp
以秒为单位的纪元时间,PHP
反之亦然。
最干净的方法是什么?
There are two functions in MySQL which are useful for converting back and forth from the unix epoch time that PHP likes:
For example, to get it back in PHP unix time, you could do:
SELECT unix_timestamp(timestamp_col) FROM tbl WHERE ...
From MySQL timestamp to epoch seconds:
strtotime($mysql_timestamp);
From epoch seconds to MySQL timestamp:
$mysql_timestamp = date('Y-m-d H:i:s', time());