 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In MySQL, how can we use FROM_UNIXTIME() function with format string?
Suppose if we want the output of FROM_UNIXIME() function in a particular format then we can use date format string or time format string or both in it. Following is the example of using the 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 query above, 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 query above, it is using only 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 query above, it is using both date and time format string.
Advertisements
 