如何在javascript中从yyyymmddhhmmss格式中获取时间

时间:2018-05-28 12:08:18

标签: javascript slice tostring

YYYYMMDDHHMMSS FORMAT

var d = new Date("20180101120000");

var k = d.toString().slice(8,10);
var l = d.toString().slice(10,12);
var m = d.toString().slice(12,14);

document.getElementById("demo").innerHTML = k + ":" + l + ":" + m +" " ;
<div id='demo'></div>

0 个答案:

没有答案