项目中维护中碰到一个问题,添加到数据库时间总是不对,不管怎么样申请时间分钟都是09,如图
申请2
在数据库中查看信息
数据库时间正确,这时查看查询sql
SELECT
a.account_code,
a.refund_amount,
a.refund_bond,
a.appeal_reason,
IFNULL(a.appeal_img,'') appeal_img,
DATE_FORMAT(
a.create_time,
'%Y-%m-%d %H:%m:%s'
) create_time,
a.appeal_process shop_state,
b.order_number,
b.order_code,
b.order_pictures,
b.flower_material,
DATE_FORMAT(
b.create_date,
'%Y-%m-%d %H:%m:%s'
) create_date,
b.amount,
b.amount_price,
c.shop_name,
c.shop_code,
d.appeal_process platform_state,
f.category_value,
d.appeal_reason twice_appeal_reason,
IFNULL(d.appeal_img,'') twice_appeal_img,
DATE_FORMAT(
d.create_time,
'%Y-%m-%d %H:%m:%s'
) twice_create_time,
d.refund_amount twice_refund_amount,
d.refund_bond twice_refund_bond,
h.category_value twice_category_value
在使用测试sql后找到了问题
SELECT
DATE_FORMAT(
a.create_time,
DATE_FORMAT( a.create_time, '%Y-%m-%d %H:%i:%s' ) create_time
由此发现,问题应该是出现在日期格式上面,然后资讯对比,发现
'%Y-%m-%d %H:%m:%s' 应该为 '%Y-%m-%d %H:%i:%s'
解决思路:
- 获取添加的时间,到数据库查看是否正确,使用 * 或单字段查询
- 如果插入正确,那么查询问题,使用原字段查询查看数据,不使用日期格式化和使用日期格式化对比数据