mysql日期函数:
1.curdate();当前日期
例子: select curdate();

2.curtime();当前时间
例子: select curtime();

3.now();当前日期和时间
例子: select now();

4.unix_timestamp();当前时间戳
例子: select unix_timestamp();

5.from_unixtime();时间戳转日期
例子: select from_unixtime(1492176896);

6.week(date);一年中的第几周
例子: select week(‘2017-1-8’);

7.year(date);日期中的年部分
例子: select year(‘2017-4-14’);

8.datediff();日期差值
例子: select datediff(‘2017-4-14’,‘2017-4-10’);


本文详细介绍了MySQL中的关键日期函数,包括获取当前日期、时间、日期和时间戳的函数,以及如何进行日期差值计算和时间戳转换。通过具体示例,读者可以快速掌握这些函数的使用方法。
5万+

被折叠的 条评论
为什么被折叠?



