Home >Database >Mysql Tutorial >How to convert timestamp in mysql time
Mysql time conversion timestamp method: 1. Get the current time through "SELECT NOW();"; 2. Convert the time and date format into timestamp format through "SELECT UNIX_TIMESTAMP(NOW());" That’s it.
#The operating environment of this article: Windows7 system, mysql8, Dell G3.
How to convert mysql time to timestamp?
Mutual conversion between MySQL timestamp and date format
Mutual conversion between MySQL timestamp and date format, Conversion between PHP timestamp and date format
MySQL:
Get the current time
SELECT NOW(); // 2018/10/11 14:22:51
Convert the time and date format to timestamp format, UNIX_TIMESTAMP( )
SELECT UNIX_TIMESTAMP(NOW()); // 1539238930
Convert timestamp format to time and date format, FROM_UNIXTIME()
SELECT FROM_UNIXTIME(1539238971); // 2018/10/11 14:22:51
PHP:
Get the current timestamp
time(); // 1539238975
Convert timestamp format to time and date format
date('Y-m-d H:i:s', time()); // 2018-10-11 14:24:06
Convert time and date format to timestamp format
strtotime('2018-10-11 14:24:06'); // 1539239046
Recommended study: "mysql video tutorial"
The above is the detailed content of How to convert timestamp in mysql time. For more information, please follow other related articles on the PHP Chinese website!