时间转字符串
select date_format(now(),'%Y-%m-%d %H:%i:%S');
输出结果:2024-01-25 15:22:03
字符串转日期或时间
select str_to_date('2024-01-25 15:05:03', '%Y-%m-%d %H:%i:%S');
输出结果:2024-01-25 15:05:03
日期转时间戳
select unix_timestamp(now());
输出结果:1706167389
时间戳转日期
select from_unixtime(1706167389);
输出结果:2024-01-25 15:23:09
时间戳转字符串
select from_unixtime(1706167389,'%Y~%m~%d %H:%i:%S');
输出结果:2024~01~25 15:23:09