
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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.
- Related Articles
- How to use MySQL FROM_UNIXTIME() function to return datetime value in numeric format?
- What is the use of MySQL FROM_UNIXTIME() function?
- How can we use MySQL SUM() function with HAVING clause?
- How can we use ASCII() function with MySQL WHERE clause?
- How can we use CHAR_LENGTH() function with MySQL WHERE clause?
- How can we use BIN() function with MySQL WHERE clause?
- How can we use FIND_IN_SET() function with MySQL WHERE clause?
- How can we use MySQL INSTR() function with WHERE clause?
- How can we use MySQL SUM() function?
- How can we know about the starting range of TIMESTAMP data type with the help of MySQL FROM_UNIXTIME() function?
- How can we use MySQL POWER() function with the column’s data values?
- How can we use MySQL EXPORT_SET() function with column of a table?
- How can we use MySQL function STR_TO_DATE(Column, ‘%input_format’)?
- In MySQL, how can we pad a string with another string?
- How can we use MySQL REVERSE() function on column’s data along with WHERE clause?

Advertisements