Home > Database > Mysql Tutorial > body text

MySQL获取系统当前时间的函数

WBOY
Release: 2016-06-07 17:26:06
Original
1928 people have browsed it

MySQL获取系统当前时间的函数,环境:MySQL Server 5.1

环境:MySQL Server 5.1

问题:MySQL获取系统当前时间的函数

解决:

NOW()函数以'YYYY-MM-DD HH:MM:SS'返回当前的日期时间,可以直接存到DATETIME字段中。

CURDATE()以'YYYY-MM-DD'的格式返回今天的日期,,可以直接存到DATE字段中。

CURTIME()以'HH:MM:SS'的格式返回当前的时间,可以直接存到TIME字段中。

示例:

SQL:

select now() as 当前日期时间;
select curdate() as 今天日期;
select curtime() as 当前时间;

linux

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