簡體   English   中英

顯示一年中的剩余月份

[英]Show remaining months in year

我想在離子 angular 或 javascript 中顯示當年的剩余月份並從當前月份刪除過去的月份。 這是我的代碼:

month = ['January', 'February', 'March', 'April', 'May', 'June', 'July',
    'August', 'September', 'October', 'November', 'December'];

currentMonth = this.month[new Date().getMonth()];

您可以使用切片

 const month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; const d = new Date(); const rest = month.slice(d.getMonth()) console.log(rest)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM