
Suppose if we want FROM_UNIXIME() function to output in a specific format, then we can use date format string or time format string or both in it. Below is an example of using format string in FROM_UNIXTIME() function -
mysql> Select FROM_UNIXTIME(1555033470 '%Y %M %D')AS 'Formatted Output'; +------------------+ | Formatted Output | +------------------+ | 2019 April 12th | +------------------+ 1 row in set (0.00 sec)
In the above query, it is using only date format string.
mysql> Select FROM_UNIXTIME(1555033470 '%h:%i:%s')AS 'Formatted Output'; +------------------+ | Formatted Output | +------------------+ | 07:14:30 | +------------------+ 1 row in set (0.00 sec)
In the above query, it uses only the time format string.
mysql> Select FROM_UNIXTIME(1555033470, '%Y %M %D %h:%i:%s')AS 'Formatted Output'; +--------------------------+ | Formatted Output | +--------------------------+ | 2019 April 12th 07:14:30 | +--------------------------+ 1 row in set (0.00 sec)
In the above query, it uses both date and time format strings.
The above is the detailed content of How can we use FROM_UNIXTIME() function with format string in MySQL?. For more information, please follow other related articles on the PHP Chinese website!
Features of raysource download tool
vcruntime140.dll cannot be found and code execution cannot continue
How to solve the invalid mysql identifier error
What are the mobile operating systems?
windows cannot open add printer
window.setinterval
What should I do if the ps temporary disk is full?
Word document encryption tutorial