Home >Database >Mysql Tutorial >How to convert timestamp in mysql time

How to convert timestamp in mysql time

藏色散人
藏色散人Original
2021-11-26 16:39:5013619browse

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.

How to convert timestamp in mysql time

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn