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 );".
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)
[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!