Syntax\n------\n\nFROM_UNIXTIME(unix_timestamp)\nFROM_UNIXTIME(unix_timestamp,format)\n\nDescription\n-----------\n\nConverts the number of seconds from the epoch (1970-01-01 00:00:00 UTC) to aTIMESTAMP value, the opposite of what UNIX_TIMESTAMP() is doing. Returns NULL if the result would be outside of the valid range of TIMESTAMP values.\n\nIf format is given, the result is exactly equivalent to\n\n``sql\nDATE_FORMAT(FROM_UNIXTIME(unix_timestamp), format)\n`\n\nTimestamps in MariaDB have a maximum value of 4294967295, equivalent to 2106-02-07 06:28:15. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nThe one-argument form of FROM_UNIXTIME() returns aDATETIME. This means that it can return values outside of valid TIMESTAMP range, in particular 1970-01-01 00:00:00. And it can return the same result for different values of unix_timestamp (around DST changes).\n\nTimestamps in MariaDB have a maximum value of 4294967295, equivalent to 2106-02-07 06:28:15. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nThe one-argument form of FROM_UNIXTIME() returns aDATETIME. This means that it can return values outside of valid TIMESTAMP range, in particular 1970-01-01 00:00:00. And it can return the same result for different values of unix_timestamp (around DST changes).\n\nThe maximum value is 2147483647, equivalent to 2038-01-19 05:14:07.\n\nThe following options can be used by FROM_UNIXTIME(), as well as DATE_FORMAT() and STR_TO_DATE():\n\n| Option | Description                                                                                                                                                                       |\n| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| %a     | Short weekday name in current locale (Variable lc_time_names). |\n| %b     | Short form month name in current locale. For locale en_US this is one of: Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov or Dec.                                                    |\n| %c     | Month with 1 or 2 digits.                                                                                                                                                         |\n| %D     | Day with English suffix 'th', 'nd', 'st' or 'rd''. (1st, 2nd, 3rd...).                                                                                                            |\n| %d     | Day with 2 digits.                                                                                                                                                                |\n| %e     | Day with 1 or 2 digits.                                                                                                                                                           |\n| %f     | Microseconds 6 digits.                                                                                                                              |\n| %H     | Hour with 2 digits between 00-23.                                                                                                                                                 |\n| %h     | Hour with 2 digits between 01-12.                                                                                                                                                 |\n| %I     | Hour with 2 digits between 01-12.                                                                                                                                                 |\n| %i     | Minute with 2 digits.                                                                                                                                                             |\n| %j     | Day of the year (001-366)                                                                                                                                                         |\n| %k     | Hour with 1 digits between 0-23.                                                                                                                                                  |\n| %l     | Hour with 1 digits between 1-12.                                                                                                                                                  |\n| %M     | Full month name in current locale (Variable lc_time_names).    |\n| %m     | Month with 2 digits.                                                                                                                                                              |\n| %p     | AM/PM according to current locale (Variable lc_time_names).    |\n| %r     | Time in 12 hour format, followed by AM/PM. Short for '%I:%i:%S %p'.                                                                                                               |\n| %S     | Seconds with 2 digits.                                                                                                                                                            |\n| %s     | Seconds with 2 digits.                                                                                                                                                            |\n| %T     | Time in 24 hour format. Short for '%H:%i:%S'.                                                                                                                                     |\n| %U     | Week number (00-53), when first day of the week is Sunday.                                                                                                                        |\n| %u     | Week number (00-53), when first day of the week is Monday.                                                                                                                        |\n| %V     | Week number (01-53), when first day of the week is Sunday. Used with %X.                                                                                                          |\n| %v     | Week number (01-53), when first day of the week is Monday. Used with %x.                                                                                                          |\n| %W     | Full weekday name in current locale (Variable lc_time_names).  |\n| %w     | Day of the week. 0 = Sunday, 6 = Saturday.                                                                                                                                        |\n| %X     | Year with 4 digits when first day of the week is Sunday. Used with %V.                                                                                                            |\n| %x     | Year with 4 digits when first day of the week is Sunday. Used with %v.                                                                                                            |\n| %Y     | Year with 4 digits.                                                                                                                                                               |\n| %y     | Year with 2 digits.                                                                                                                                                               |\n| %#     | For str_to_date(), skip all numbers.                                                                                                                          |\n| %.     | For str_to_date(), skip all punctation characters.                                                                                                            |\n| %@     | For str_to_date(), skip all alpha characters.                                                                                                                 |\n| %%     | A literal % character.                                                                                                                                                            |\n\nPerformance Considerations\n\nIf your session time zone is set to SYSTEM (the default), FROM_UNIXTIME() will call the OS function to convert the data using the system time zone. At least on Linux, the corresponding function (localtime_r`) uses a global mutex inside glibc that can cause contention under high concurrent load.\n\nSet your time zone to a named time zone to avoid this issue. See mysql time zone tables for details on how to do this.\n\nExamples\n--------\n\nSELECT FROM_UNIXTIME(1196440219);\n+---------------------------+\n| FROM_UNIXTIME(1196440219) |\n+---------------------------+\n| 2007-11-30 11:30:19       |\n+---------------------------+\n\nSELECT FROM_UNIXTIME(1196440219) + 0;\n+-------------------------------+\n| FROM_UNIXTIME(1196440219) + 0 |\n+-------------------------------+\n|         20071130113019.000000 |\n+-------------------------------+\n\nSELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y %D %M %h:%i:%s %x');\n+---------------------------------------------------------+\n| FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y %D %M %h:%i:%s %x') |\n+---------------------------------------------------------+\n| 2010 27th March 01:03:47 2010                           |\n+---------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/from_unixtime