node.js查询 mysql 时间等于 undefined 不能使用


const sqldate = 'select Registration_time from users'
db.query(sqldate,(err,results)=>{
            if(err) return console.log('no');
            console.log(results.Registration_time);
        })

上方查询出来后,console.log(results.Registration_time); 就等于undefined
而 console.log(results); 便可以显示时间(如下图)

img

但是都不能用,所有有没有人知道,怎么将查询出来的时间弄成这种(2022-5-5 18:5:12)类型的,并且可用

https://my.oschina.net/u/4321213/blog/3694344
参考这篇文章试一下

1.将返回的结果反序列化成对象2.定义一个格式化时间函数