使用 moment.js,您可以这样格式化日期:
const date = moment("2010-10-22T21:38:00");
const data = date.format("LL - LT")
console.log(data)
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.0/moment.min.js" integrity="sha512-Izh34nqeeR7/nwthfeE0SI3c8uhFSnqxV0sI9TvTcXiFJkMd6fB644O64BRq2P/LA/+7eRvCw4GmLsXksyTHBg==" crossorigin="anonymous"></script>
如何用 Luxon 做同样的事情?我试过了:
const date = luxon.DateTime.fromISO("2010-10-22T21:38:00" );
const data = luxon.DateTime.fromFormat(date, "DATETIME_SHORT")
// output => script error
<script src="https://cdn.jsdelivr.net/npm/luxon@1.25.0/build/global/luxon.min.js"></script>