Mybatis日期和字符串相互转化
目录
一、日期转字符串
内置函数:date_format(date, format)
二、日期转时间戳
内置函数:unix_timestamp(date)
三、字符串转日期
内置函数:str_to_date(str,format);
注意:format格式必须和str的格式相同,否则返回空
四、时间戳转日期
内置函数:from_unixtime(timestamp);
五、时间戳转字符串
内置函数:from_unixtime(timestamp,format);
六、常用format示例
SELECT date_format( now( ), '%Y-%m-%d %H:%i:%s' );

七、附录参考表

浙公网安备 33010602011771号