toLocalString() 是我个人比较喜欢的
let time = new Date(); console.log("toDateString:", time.toDateString()); console.log("toString:", time.toString()); console.log("toTimeString:", time.toTimeString()); console.log("toLocaleString:", time.toLocaleString()); console.log("toLocaleDateString:", time.toLocaleDateString()); console.log("toLocaleTimeString:", time.toLocaleTimeString()); console.log("toUTCString:", time.toUTCString()); console.log("toISOString:", time.toISOString()); console.log("valueOf:", time.valueOf()); console.log("getTime:", time.getTime()); //==================输出============== toDateString: Wed Jun 24 2020 toString: Wed Jun 24 2020 16:01:18 GMT+0800 (GMT+08:00) toTimeString: 16:01:18 GMT+0800 (GMT+08:00) toLocaleString: 2020-6-24 16:01:18 toLocaleDateString: 2020-6-24 toLocaleTimeString: 16:01:18 toUTCString: Wed, 24 Jun 2020 08:01:18 GMT toISOString: 2020-06-24T08:01:18.497Z valueOf: 1592985678497 getTime: 1592985678497