Node.js 用于在节点js中转换月字符串格式的日期编号格式

Node.js 用于在节点js中转换月字符串格式的日期编号格式,node.js,date-formatting,Node.js,Date Formatting,日期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("-")); 设置日期格式的最佳方法 <!DOCTY

日期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>


var d=新日期(“8-1-20”); document.getElementById(“demo”).innerHTML=d.toLocaleDateString('en-GB'{ 日期:'2位', 月份:'长', 年份:'数字' });
输出

2020年8月1日