Home > Database > Mysql Tutorial > body text

How to convert timestamp to date in mysql

coldplay.xixi
Release: 2020-10-09 14:16:51
Original
12818 people have browsed it

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日')
Copy after login

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')
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template