目的:整理mysql中日期和字符串的相互转化的一些函数 一、日期转字符串 1、函数:date_format(date, format) 2、例:
二、日期转时间戳 1、函数:unix_timestamp(data) 2、例:
三、字符串转日期 1、函数:str_to_date(str,format);注:format格式必须和str的格式相同,否则返回空 2、例:
四、时间戳转日期 1、函数:from_unixtime(time-stamp); 2、例:
五、时间戳转字符串 1、函数:from_unixtime(time-stamp,format); 2、例:
附录: MySQL日期格式化(format)取值范围。 参考:http://www.cnblogs.com/wangyongwen/p/6265126.html |
|
来自: melodyjian > 《mysql》