标签 mysql 下的文章

日期和时间戳互换

FROM_UNIXTIME(unixtime, format) 将时间戳转换为日期时间字符串
UNIX_TIMESTAMP(date) 将指定的日期或者日期字符串转换为时间戳
DATE_FORMAT(date, format) 根据参数对date进行格式化

获取当前日期、时间

select now(); 或 select current_timestamp(); //获得当前时间  格式:2016-01-12 23:19:43
select curdate(); 或 select current_date(); //获得当前时间  格式: 2016-01-12
select current_date()+0;  //获得当前时间  格式: 20160112
select curtime(); 或 select current_time(); //获得当前时间  格式:23:19:43

- 阅读剩余部分 -