![](/img/trans.png)
[英]CSS: How can I have a “scatter display of words” rather than the html default display up/down?
[英]How do I display the day output as Thursday, Dec 16 rather than MM/DD in CSS / HTML
我試圖弄清楚如何以更用戶友好的方式顯示此代碼,而不是顯示為 MM/DD ex。 “12/20”我寧願說日期名稱、月份的前 3 個字母和 DD,例如“Monday, Dec 20”。 那可能嗎? 請在下面找到代碼。
/* js file for autocalculate shipping*/
(function() {
// estimate the delivery date
var dateEnd = 3;
var toDate = Date.today().addDays(dateEnd);
if (toDate.is().saturday() || toDate.is().sunday()) {
toDate = toDate.next().monday();
}
document.getElementById('toDate').innerHTML = toDate.toString('MM/dd');
})();
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] const months = ["Dec","Nov","Oct","Sep","Aug","Jul","Jun","May","Apr","Mar","Feb","Jan"] const getFormattedDate = (date) => { return `${days[date.getDay()]} - ${months[date.getMonth()]} - ${date.getFullYear()}` } let d = new Date(); console.log(getFormattedDate(d))
let date = moment() console.log(date.format('ddd MMM YY'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.