FROM_UNIXTIME()

Overview

Returns a date-time value based on a Unix seconds-since-epic numeric value.

USAGE

FROM_UNIXTIME(seconds[, format])

Argument Name

Description

seconds

The Unix seconds-since-epoch numeric value

format

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

%a

Abbreviated weekday name in the current locale

%b

Abbreviated month name in the current locale

%c

Month number in 1 or 2 digits

%D

Day number with English suffix "st", "nd", "rd", or "th"

%d

Day number in 2 digits

%e

Day number in 1 or 2 digits

%f

Microseconds (6 digits)

%H

Hour in 2 digits (00-23)

%h

Hour in 2 digits (01-12)

%I

Hour in 2 digits (01-12)

%i

Minute in 2 digits

%j

Numeric day of the year in 3 digits (001-366)

%k

Hour in 1 to 2 digits (0-23)

%l

Hour in 1 to 2 digits (1-12)

%M

Full month name in the current locale

%m

Month number in 2 digits

%p

AM or PM according to the current locale

%r

An alias for %I:%i:%S %p

%S

Seconds in 2 digits

%s

Seconds in 2 digits

%T

An alias for "%H:%i:%S"

%U

Week number (00-53) starting on Sunday

%u

Week number (00-53) starting on Monday

%V

Week number (01-53) starting on Sunday

%v

Week number (01-53) starting on Monday

%W

Full weekday name in current locale

%w

Day of the week (Sunday is 0)

%X

Year with 4 digits according to %V

%x

Year with 4 digits according to %v

%Y

Year with 4 digits

%y

Year with 2 digits

%%

A literal % character

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

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                      |
+-------------------------------------------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES