---
title: "mysql 时间函数使用"
author: "fantaoyalin"
date: "2012-08-20T15:12:13Z"
tags: ["MySQL"]
categories: ["企业架构"]
slug: "mysql"
draft: false
lastmod: "2012-08-20T15:12:13Z"
id: 1638464
url: "https://fantaoyalin.iteye.com/blog/1638464"
---

游戏运维人员对时间函数使用的多，不知真假


```java


一、MySQL 获得当前日期时间 函数
1.1 获得当前日期+时间（date + time）函数：now()
mysql> select now();

+---------------------+
| now() |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+

除了 now() 函数能获得当前的日期时间外，MySQL 中还有下面的函数：
current_timestamp()
,current_timestamp
,localtime()
,localtime
,localtimestamp -- (v4.0.6)
,localtimestamp() -- (v4.0.6)

这些日期时间函数，都等同于 now()。鉴于 now() 函数简短易记，建议总是使用 now() 来替代上面列出的函数

```