Home > Database > Mysql Tutorial > A brief introduction to mysql time functions and examples

A brief introduction to mysql time functions and examples

零下一度
Release: 2017-05-04 15:54:38
Original
1248 people have browsed it

This article briefly introduces the time function and examples of mysql. Interested friends can refer to the time

function of

##mysql:

 FROM_UNIXTIME
    FROM_UNIXTIME(unix_timestamp, format)
Copy after login

The first parameter is the

timestamp

format. The second is the format you want to convert ultimately, such as

   SELECT FROM_UNIXTIME(1436102304,'%Y年%m月%d日') as date;
Copy after login

Result Date : July 5, 2015


    UNIX_TIMESTAMP
    UNIX_TIMESTAMP(date)
Copy after login

is to convert time into time Poke, such as

   SELECT UNIX_TIMESTAMP('2015-07-05');
Copy after login

The result is: 1436068800

Example: Find the records in the log table from 2015-05 to 2015-07:

   SELECT id, FROM_UNIXTIME(time,'%Y-%m-%d') as date 
       FROM log 
       WHERE  time BETWEEN UNIX_TIMESTAMP('2015-05-01') AND UNIX_TIMESTAMP('2015-07-01');
Copy after login

[Related recommendations]

1.

Free mysql online video tutorial

2.

MySQL latest manual tutorial

3.

Boolean Education Yan Shiba mysql introductory video tutorial

The above is the detailed content of A brief introduction to mysql time functions and examples. 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