Home >Database >Mysql Tutorial >How to convert timestamp to date in mysql

How to convert timestamp to date in mysql

coldplay.xixi
coldplay.xixiOriginal
2020-10-09 14:16:5112836browse

Mysql method to convert timestamp to date: use function [FROM_UNIXTIME()], the code is [select FROM_UNIXTIME(1429063399,'%Y year %m month %d day')].

How to convert timestamp to date in mysql

Mysql method to convert timestamp to date:

1. Convert timestamp to date

Function: FROM_UNIXTIME()

select FROM_UNIXTIME(1429063399,'%Y年%m月%d日')

The result is: April 15, 2015

2. Convert the date to a timestamp, which is exactly the opposite of FROM_UNIXTIME

Function : UNIX_TIMESTAMP()

select UNIX_TIMESTAMP('2015-04-15')

The result is: 1429027200

Related free learning recommendations: mysql database (video)

The above is the detailed content of How to convert timestamp to date in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more