在数据库中可以使用 DATE_FORMAT(date,format)进行时间格式化
date 参数是合法的日期
format 参数规定日期/时间的输出格式
把时间格式化成字符串
Oracle 格式化函数 to_char
select to_char( sysdate , 'yyyy/mm/dd') from dual;
Mysql 格式化函数
-- %Y 年,4 位
-- %m 月,数值(00-12)
-- %d 月的天,数值(00-31)
-- %H 小时 (00-23)
-- %i 分钟,数值(00-59)
-- %S 秒(00-59)
select date_format( now() , '%Y-%m-%d %H:%i:%S')