質問編集履歴
2
微調整
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
const dt = new Date('2021-12-22T09:00:00.000Z');
|
8
8
|
// 各月の1日を取得
|
9
9
|
const pdtf = new Date(dt.getFullYear(), dt.getMonth() - 1, 1, 0, 0, 1); // 先月
|
10
|
-
const tdtf = new Date(dt.getFullYear(), dt.getMonth(),
|
10
|
+
const tdtf = new Date(dt.getFullYear(), dt.getMonth(), 1, 0, 0, 1); // 今月
|
11
11
|
const ndtf = new Date(dt.getFullYear(), dt.getMonth() + 1, 1, 0, 0, 1); // 来月
|
12
12
|
// 各月の末日を取得
|
13
|
-
const pdtl = new Date(dt.getFullYear(), dt.getMonth(),
|
13
|
+
const pdtl = new Date(dt.getFullYear(), dt.getMonth(), 0, 0, 23, 59, 59); // 先月
|
14
14
|
const tdtl = new Date(dt.getFullYear(), dt.getMonth() + 1, 0, 23, 59, 59); // 今月
|
15
15
|
const ndtl = new Date(dt.getFullYear(), dt.getMonth() + 2, 0, 23, 59, 59); // 来月
|
16
16
|
console.log(dt)
|
1
コードを読みやすく微調整した
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
const dt = new Date('2021-12-22T09:00:00.000Z');
|
8
8
|
// 各月の1日を取得
|
9
9
|
const pdtf = new Date(dt.getFullYear(), dt.getMonth() - 1, 1, 0, 0, 1); // 先月
|
10
|
-
const tdtf = new Date(dt.getFullYear(), dt.getMonth(), 1,
|
10
|
+
const tdtf = new Date(dt.getFullYear(), dt.getMonth(), 1, 0, 0, 1); // 今月
|
11
11
|
const ndtf = new Date(dt.getFullYear(), dt.getMonth() + 1, 1, 0, 0, 1); // 来月
|
12
12
|
// 各月の末日を取得
|
13
|
-
const pdtl = new Date(dt.getFullYear(), dt.getMonth(), 0, 23, 59, 59);
|
13
|
+
const pdtl = new Date(dt.getFullYear(), dt.getMonth(), 0, 0, 23, 59, 59); // 先月
|
14
14
|
const tdtl = new Date(dt.getFullYear(), dt.getMonth() + 1, 0, 23, 59, 59); // 今月
|
15
15
|
const ndtl = new Date(dt.getFullYear(), dt.getMonth() + 2, 0, 23, 59, 59); // 来月
|
16
16
|
console.log(dt)
|