Convert timestamp in MySQL


UNIX_TIMESTAMP

UNIX_TIMESTAMP returns the seconds since 1970-01-01 00:00:00 UTC:

UNIX_TIMESTAMP() /* 1598832000 */

You can pass a date argument to the function:

UNIX_TIMESTAMP('2020-08-31 00:00:00') /* 1598832000 */

FROM_UNIXTIME

FROM_UNIXTIME returns the timestamp in YYYY-MM-DD hh:mm:ss format:

FROM_UNIXTIME('1598832000') /* 2020-08-31 00:00:00.000000 */


Please support this site and join our Discord!