0
私はブートストラップ4と角度2とngbを使用しています。ユーザーをNGBからdatepickerでngb datepickerで平日(曜日)を取得する
は、日付を選択し、私は簡単に日付構造のbecaue、日、月、年を取得することができます:
Model: {
"year": 2017,
"month": 10,
"day": 25
}
しかし、私はまた、曜日を必要とします。私はapiでこれに関する情報を見つけることができません。それは可能なのか、平日になるのに良い方法はありますか?私はこれまでやった
は次のとおりです。
this.date = this.datepicked.year + "-" + this.datepicked.month + "-" + this.datepicked.day;
let date = new Date(this.date);
this.day_of_week = date.getDay();
は(NGBでサポートされている)よりエレガントな解決策はありますか?
挨拶、 シュテフィ
MomentJS lib - https://momentjs.com/をご覧ください。これは、すべての日付操作と日付機能のためのソリューションを提供します – galvan
新しい日付(this.datepicked.year、this.datepicked.month-1、this。 datepicked.day).getDay()? – Eliseo