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

A brief introduction to mysql time functions and examples

零下一度
零下一度Original
2017-05-04 15:54:381223browse

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)

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;

Result Date : July 5, 2015


    UNIX_TIMESTAMP
    UNIX_TIMESTAMP(date)

is to convert time into time Poke, such as

   SELECT UNIX_TIMESTAMP('2015-07-05');

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');

[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!

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