Home > Database > Mysql Tutorial > body text

How to convert seconds to time in mysql

青灯夜游
Release: 2022-01-04 17:30:58
Original
5732 people have browsed it

In mysql, you can use the FROM_UNIXTIME() function to convert seconds to time. This function can convert the timestamp (total seconds) into a common format date and time value. The syntax is "SELECT FROM_UNIXTIME(date );".

How to convert seconds to time in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

In mysql, you can use the FROM_UNIXTIME() function to convert seconds to time.

FROM_UNIXTIME(date) The function converts the UNIX timestamp (the total number of seconds from January 1, 1970 00:00:00 GMT to the present) Convert to a date-time value in common format ('YYYY-MM-DD HH:MM:SS' or a date-time value in YYYYMMDDHHMMSS format).

[Example] Use the FROM_UNIXTIME(date) function to convert UNIX timestamps into common format time.

mysql> SELECT FROM_UNIXTIME(1150051270);
+---------------------------+
| FROM_UNIXTIME(1150051270) |
+---------------------------+
| 2006-06-12 02:41:10       |
+---------------------------+
1 row in set (0.00 sec)
Copy after login

[Related recommendations: mysql video tutorial]

The above is the detailed content of How to convert seconds to time in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template