FROM_UNIXTIME()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a date-time value based on a Unix seconds-since-epic numeric value.
USAGE
FROM_UNIXTIME(seconds[, format])
Argument Name | Description |
---|---|
| The Unix seconds-since-epoch numeric value |
| The format to use |
DETAILS
FROM_UNIXTIME()
returns a date-time value based on a Unix seconds-since-epoch numeric value.
The Unix epoch started at 1970-01-01 00:00:00
UTC.
The seconds
value can be a decimal value with up to 6 digits of accuracy (which specifies the microseconds).
In string context, the return value has the default format of YYYY-MM-DD hh:mm:ss
.
In numeric context, the return value has the default format of YYYYMMDDhhmmss
.
The date-time value is rendered in the session's default time zone.
A NULL
is returned if either argument is NULL
.
The optional format
argument can be used to render the returned value using whatever information you require.
Option | Description |
---|---|
| Abbreviated weekday name in the current locale |
| Abbreviated month name in the current locale |
| Month number in 1 or 2 digits |
| Day number with English suffix "st", "nd", "rd", or "th" |
| Day number in 2 digits |
| Day number in 1 or 2 digits |
| Microseconds (6 digits) |
| Hour in 2 digits (00-23) |
| Hour in 2 digits (01-12) |
| Hour in 2 digits (01-12) |
| Minute in 2 digits |
| Numeric day of the year in 3 digits (001-366) |
| Hour in 1 to 2 digits (0-23) |
| Hour in 1 to 2 digits (1-12) |
| Full month name in the current locale |
| Month number in 2 digits |
| AM or PM according to the current locale |
| An alias for |
| Seconds in 2 digits |
| Seconds in 2 digits |
| An alias for "%H:%i:%S" |
| Week number (00-53) starting on Sunday |
| Week number (00-53) starting on Monday |
| Week number (01-53) starting on Sunday |
| Week number (01-53) starting on Monday |
| Full weekday name in current locale |
| Day of the week (Sunday is 0) |
| Year with 4 digits according to |
| Year with 4 digits according to |
| Year with 4 digits |
| Year with 2 digits |
| A literal |
EXAMPLES
SELECT FROM_UNIXTIME(1500000000);
+---------------------------+
| FROM_UNIXTIME(1500000000) |
+---------------------------+
| 2017-07-14 02:40:00 |
+---------------------------+
SELECT FROM_UNIXTIME(1500000000, '%a, %b %e %T');
+-------------------------------------------+
| FROM_UNIXTIME(1500000000, '%a, %b %e %T') |
+-------------------------------------------+
| Fri, Jul 14 02:40:00 |
+-------------------------------------------+