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

How to convert timestamp in mysql time

藏色散人
Release: 2021-11-26 16:39:50
Original
13753 people have browsed it

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
Copy after login

Convert the time and date format to timestamp format, UNIX_TIMESTAMP( )

SELECT UNIX_TIMESTAMP(NOW()); // 1539238930
Copy after login

Convert timestamp format to time and date format, FROM_UNIXTIME()

SELECT FROM_UNIXTIME(1539238971); // 2018/10/11 14:22:51
Copy after login

PHP:

Get the current timestamp

time();    // 1539238975
Copy after login

Convert timestamp format to time and date format

date('Y-m-d H:i:s', time()); // 2018-10-11 14:24:06
Copy after login

Convert time and date format to timestamp format

strtotime('2018-10-11 14:24:06'); // 1539239046
Copy after login

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!

Related labels:
Statement of this Website
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template