JavaScript  方法

date to string
let s = new Date().toLocaleString();

console/log(s) 

 

====
string to date
var date = new Date(“2018-9-21 14:58:43”);//就是这么简单