日期 8-1-20 这是我想要转换为的日期,就像这个日期格式一样。
let formatedDate_cd = new Intl.DateTimeFormat('en-GB',{
day:'2-digit',
month:'long',
year:'numeric'
}).format(close_date_)
console.log(formatedDate_cd.split(" ").join("-"));
设置日期格式的最佳方法
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var d = new Date("8-1-20");
document.getElementById("demo").innerHTML = d.toLocaleDateString('en-GB',{
day:'2-digit',
month:'long',
year:'numeric'
});
</script>
</body>
</html>
输出
01 八月 2020