使用 moment.js 设置可变日期值
Posted
技术标签:
【中文标题】使用 moment.js 设置可变日期值【英文标题】:Set variable date value with moment.js 【发布时间】:2021-10-09 12:16:14 【问题描述】:我正在使用日期范围选择器使用 this example 的数据表。
我想删除日期选择器,只在表格加载时设置开始和结束日期变量值。我试过无济于事。我能得到的最接近的是通过预先设置最小和最大日期范围输入字段值,如下所示:
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex )
var min = minDate.val();
var max = maxDate.val();
var date = new Date( data[0] );
if (
( min === null && max === null ) ||
( min === null && date <= max ) ||
( min <= date && max === null ) ||
( min <= date && date <= max )
)
return true;
return false;
);
和:
minDate = new DateTime($('#min'),
format: 'YYYY-MM-DD'
);
maxDate = new DateTime($('#max'),
format: 'YYYY-MM-DD'
);
$("#max").val(moment().format('YYYY-MM-DD'));
$("#min").val(moment().subtract(7, 'd').format('YYYY-MM-DD'));
我的目标是删除这两个输入字段,并将 'min' 和 'max' 变量设置为上述值。
我已经设置了jsfiddle here。任何人都可以伸出援助之手吗?谢谢:)
【问题讨论】:
你所说的“达到上述值”是什么意思? @0stone0指的是他创建的 #max #min 值,它始终代表当天和当天前 7 天 【参考方案1】:在这里,您只需将 CSS 样式应用于包含 #min
#max
值的第一个表,它们仍将读取使用 javascript 插入的输入。
我将 ID #maxmin
应用于包含两个日期范围的第一个表。然后在 CSS 中,我可以调用该 ID 并将其设置为 display: none;
var minDate, maxDate;
// Custom filtering function which will search data in column four between two values
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex )
var min = minDate.val();
var max = maxDate.val();
var date = new Date( data[0] );
if (
( min === null && max === null ) ||
( min === null && date <= max ) ||
( min <= date && max === null ) ||
( min <= date && date <= max )
)
return true;
return false;
);
$(document).ready(function()
// Create date inputs
minDate = new DateTime($('#min'),
format: 'YYYY-MM-DD'
);
maxDate = new DateTime($('#max'),
format: 'YYYY-MM-DD'
);
$("#max").val(moment().format('YYYY-MM-DD'));
$("#min").val(moment().subtract(7, 'd').format('YYYY-MM-DD'));
// DataTables initialisation
var table = $('#chart_data').DataTable();
table.draw();
// Refilter the table
$('#min, #max').on('change', function ()
table.draw();
);
);
#maxmin
display: none;
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/datetime/1.1.0/css/dataTables.dateTime.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://cdn.datatables.net/datetime/1.1.0/js/dataTables.dateTime.min.js"></script>
</head>
<body>
<table border="0" cellspacing="5" cellpadding="5" id="maxmin">
<tbody><tr>
<td>Minimum date:</td>
<td><input type="text" id="min" name="min"></td>
</tr>
<tr>
<td>Maximum date:</td>
<td><input type="text" id="max" name="max"></td>
</tr>
</tbody></table>
<table id="chart_data">
<thead>
<tr>
<th>Date</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<tr>
<td>2021-08-04</td>
<td>1</td>
</tr>
<tr>
<td>2021-08-03</td>
<td>1</td>
</tr>
<tr>
<td>2021-08-02</td>
<td>1</td>
</tr>
<tr>
<td>2021-07-29</td>
<td>2</td>
</tr>
<tr>
<td>2021-07-28</td>
<td>1</td>
</tr>
<tr>
<td>2021-07-27</td>
<td>1</td>
</tr>
<tr>
<td>2021-07-26</td>
<td>2</td>
</tr>
<tr>
<td>2021-07-23</td>
<td>1</td>
</tr>
<tr>
<td>2021-07-22</td>
<td>1</td>
</tr>
<tr>
<td>2021-07-21</td>
<td>4</td>
</tr>
<tr>
<td>2021-07-20</td>
<td>1</td>
</tr>
<tr>
<td>2021-07-19</td>
<td>5</td>
</tr>
<tr>
<td>2021-07-16</td>
<td>3</td>
</tr>
<tr>
<td>2021-07-15</td>
<td>5</td>
</tr>
<tr>
<td>2021-07-14</td>
<td>2</td>
</tr>
<tr>
<td>2021-07-13</td>
<td>8</td>
</tr>
<tr>
<td>2021-07-12</td>
<td>5</td>
</tr>
<tr>
<td>2021-07-09</td>
<td>8</td>
</tr>
<tr>
<td>2021-07-08</td>
<td>1</td>
</tr>
<tr>
<td>2021-07-07</td>
<td>3</td>
</tr>
<tr>
<td>2021-07-06</td>
<td>2</td>
</tr>
<tr>
<td>2021-07-05</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-28</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-25</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-24</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-23</td>
<td>2</td>
</tr>
<tr>
<td>2021-06-22</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-21</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-17</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-16</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-15</td>
<td>2</td>
</tr>
<tr>
<td>2021-06-14</td>
<td>3</td>
</tr>
<tr>
<td>2021-06-09</td>
<td>2</td>
</tr>
<tr>
<td>2021-06-07</td>
<td>2</td>
</tr>
<tr>
<td>2021-06-04</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-03</td>
<td>4</td>
</tr>
<tr>
<td>2021-06-02</td>
<td>1</td>
</tr>
<tr>
<td>2021-06-01</td>
<td>1</td>
</tr>
<tr>
<td>2021-05-27</td>
<td>2</td>
</tr>
<tr>
<td>2021-05-25</td>
<td>2</td>
</tr>
<tr>
<td>2021-05-24</td>
<td>1</td>
</tr>
<tr>
<td>2021-05-21</td>
<td>2</td>
</tr>
<tr>
<td>2021-05-20</td>
<td>1</td>
</tr>
<tr>
<td>2021-05-18</td>
<td>2</td>
</tr>
<tr>
<td>2021-05-17</td>
<td>4</td>
</tr>
<tr>
<td>2021-05-13</td>
<td>1</td>
</tr>
<tr>
<td>2021-05-12</td>
<td>1</td>
</tr>
<tr>
<td>2021-05-11</td>
<td>1</td>
</tr>
<tr>
<td>2021-05-10</td>
<td>1</td>
</tr>
<tr>
<td>2021-05-07</td>
<td>2</td>
</tr>
<tr>
<td>2021-05-06</td>
<td>1</td>
</tr>
<tr>
<td>2021-05-04</td>
<td>2</td>
</tr>
<tr>
<td>2021-04-30</td>
<td>1</td>
</tr>
<tr>
<td>2021-04-29</td>
<td>2</td>
</tr>
<tr>
<td>2021-04-28</td>
<td>3</td>
</tr>
<tr>
<td>2021-04-27</td>
<td>1</td>
</tr>
<tr>
<td>2021-04-22</td>
<td>3</td>
</tr>
<tr>
<td>2021-04-21</td>
<td>1</td>
</tr>
<tr>
<td>2021-04-20</td>
<td>4</td>
</tr>
<tr>
<td>2021-04-19</td>
<td>3</td>
</tr>
<tr>
<td>2021-04-15</td>
<td>2</td>
</tr>
<tr>
<td>2021-04-13</td>
<td>2</td>
</tr>
<tr>
<td>2021-03-31</td>
<td>2</td>
</tr>
<tr>
<td>2021-03-30</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-29</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-26</td>
<td>4</td>
</tr>
<tr>
<td>2021-03-24</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-23</td>
<td>4</td>
</tr>
<tr>
<td>2021-03-22</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-19</td>
<td>3</td>
</tr>
<tr>
<td>2021-03-18</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-17</td>
<td>2</td>
</tr>
<tr>
<td>2021-03-15</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-12</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-11</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-10</td>
<td>3</td>
</tr>
<tr>
<td>2021-03-09</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-08</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-05</td>
<td>3</td>
</tr>
<tr>
<td>2021-03-04</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-03</td>
<td>2</td>
</tr>
<tr>
<td>2021-03-02</td>
<td>1</td>
</tr>
<tr>
<td>2021-03-01</td>
<td>1</td>
</tr>
<tr>
<td>2021-02-26</td>
<td>1</td>
</tr>
<tr>
<td>2021-02-25</td>
<td>1</td>
</tr>
<tr>
<td>2021-02-24</td>
<td>2</td>
</tr>
<tr>
<td>2021-02-23</td>
<td>4</td>
</tr>
<tr>
<td>2021-02-22</td>
<td>1</td>
</tr>
<tr>
<td>2021-02-19</td>
<td>1</td>
</tr>
<tr>
<td>2021-02-18</td>
<td>1</td>
</tr>
<tr>
<td>2021-02-17</td>
<td>1</td>
</tr>
<tr>
<td>2021-02-16</td>
<td>1</td>
</tr>
<tr>
<td>2021-02-12</td>
<td>2</td>
</tr>
<tr>
<td>2021-02-11</td>
<td>3</td>
</tr>
<tr>
<td>2021-02-10</td>
<td>2</td>
</tr>
<tr>
<td>2021-02-09</td>
<td>1</td>
</tr>
<tr>
<td>2021-02-05</td>
<td>5</td>
</tr>
<tr>
<td>2021-02-04</td>
<td>3</td>
</tr>
<tr>
<td>2021-02-03</td>
<td>12</td>
</tr>
<tr>
<td>2021-02-01</td>
<td>1</td>
</tr>
<tr>
<td>2021-01-29</td>
<td>3</td>
</tr>
<tr>
<td>2021-01-28</td>
<td>1</td>
</tr>
<tr>
<td>2021-01-27</td>
<td>1</td>
</tr>
<tr>
<td>2021-01-25</td>
<td>3</td>
</tr>
<tr>
<td>2021-01-22</td>
<td>3</td>
</tr>
<tr>
<td>2021-01-21</td>
<td>6</td>
</tr>
<tr>
<td>2021-01-20</td>
<td>2</td>
</tr>
<tr>
<td>2021-01-19</td>
<td>1</td>
</tr>
<tr>
<td>2021-01-18</td>
<td>1</td>
</tr>
<tr>
<td>2021-01-14</td>
<td>2</td>
</tr>
<tr>
<td>2021-01-13</td>
<td>2</td>
</tr>
<tr>
<td>2021-01-07</td>
<td>3</td>
</tr>
<tr>
<td>2021-01-06</td>
<td>2</td>
</tr>
<tr>
<td>2020-12-23</td>
<td>6</td>
</tr>
<tr>
<td>2020-12-21</td>
<td>4</td>
</tr>
<tr>
<td>2020-12-18</td>
<td>1</td>
</tr>
<tr>
<td>2020-12-16</td>
<td>2</td>
</tr>
<tr>
<td>2020-12-15</td>
<td>1</td>
</tr>
<tr>
<td>2020-12-14</td>
<td>1</td>
</tr>
<tr>
<td>2020-12-13</td>
<td>1</td>
</tr>
<tr>
<td>2020-12-08</td>
<td>1</td>
</tr>
<tr>
<td>2020-12-07</td>
<td>1</td>
</tr>
<tr>
<td>2020-12-04</td>
<td>18</td>
</tr>
<tr>
<td>2020-12-03</td>
<td>6</td>
</tr>
<tr>
<td>2020-12-02</td>
<td>1</td>
</tr>
<tr>
<td>2020-12-01</td>
<td>4</td>
</tr>
<tr>
<td>2020-11-30</td>
<td>4</td>
</tr>
<tr>
<td>2020-11-24</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-23</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-19</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-18</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-16</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-13</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-12</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-10</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-09</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-06</td>
<td>1</td>
</tr>
<tr>
<td>2020-11-05</td>
<td>3</td>
</tr>
<tr>
<td>2020-11-04</td>
<td>1</td>
</tr>
<tr>
<td>2020-10-28</td>
<td>2</td>
</tr>
<tr>
<td>2020-10-27</td>
<td>2</td>
</tr>
<tr>
<td>2020-10-26</td>
<td>1</td>
</tr>
<tr>
<td>2020-10-23</td>
<td>3</td>
</tr>
<tr>
<td>2020-10-22</td>
<td>1</td>
</tr>
<tr>
<td>2020-10-21</td>
<td>5</td>
</tr>
<tr>
<td>2020-10-20</td>
<td>1</td>
</tr>
<tr>
<td>2020-10-14</td>
<td>1</td>
</tr>
<tr>
<td>2020-10-09</td>
<td>1</td>
</tr>
<tr>
<td>2020-10-08</td>
<td>3</td>
</tr>
<tr>
<td>2020-10-07</td>
<td>1</td>
</tr>
<tr>
<td>2020-10-01</td>
<td>3</td>
</tr>
<tr>
<td>2020-09-30</td>
<td>2</td>
</tr>
<tr>
<td>2020-09-25</td>
<td>2</td>
</tr>
<tr>
<td>2020-09-24</td>
<td>6</td>
</tr>
<tr>
<td>2020-09-23</td>
<td>4</td>
</tr>
<tr>
<td>2020-09-21</td>
<td>1</td>
</tr>
<tr>
<td>2020-09-18</td>
<td>2</td>
</tr>
<tr>
<td>2020-09-17</td>
<td>1</td>
</tr>
<tr>
<td>2020-09-16</td>
<td>6</td>
</tr>
<tr>
<td>2020-09-15</td>
<td>2</td>
</tr>
<tr>
<td>2020-09-14</td>
<td>3</td>
</tr>
<tr>
<td>2020-09-11</td>
<td>1</td>
</tr>
<tr>
<td>2020-09-10</td>
<td>1</td>
</tr>
<tr>
<td>2020-09-09</td>
<td>2</td>
</tr>
<tr>
<td>2020-09-08</td>
<td>1</td>
</tr>
<tr>
<td>2020-09-04</td>
<td>1</td>
</tr>
<tr>
<td>2020-09-03</td>
<td>1</td>
</tr>
<tr>
<td>2020-09-01</td>
<td>3</td>
</tr>
<tr>
<td>2020-08-31</td>
<td>5</td>
</tr>
<tr>
<td>2020-08-28</td>
<td>1</td>
</tr>
<tr>
<td>2020-08-27</td>
<td>3</td>
</tr>
<tr>
<td>2020-08-26</td>
<td>8</td>
</tr>
<tr>
<td>2020-08-25</td>
<td>1</td>
</tr>
<tr>
<td>2020-08-24</td>
<td>6</td>
</tr>
<tr>
<td>2020-08-21</td>
<td>5</td>
</tr>
<tr>
<td>2020-08-20</td>
<td>5</td>
</tr>
<tr>
<td>2020-08-19</td>
<td>4</td>
</tr>
<tr>
<td>2020-08-17</td>
<td>12</td>
</tr>
<tr>
<td>2020-08-13</td>
<td>2</td>
</tr>
<tr>
<td>2020-08-12</td>
<td>3</td>
</tr>
<tr>
<td>2020-08-11</td>
<td>12</td>
</tr>
<tr>
<td>2020-08-10</td>
<td>1</td>
</tr>
<tr>
<td>2020-08-06</td>
<td>4</td>
</tr>
<tr>
<td>2020-08-04</td>
<td>2</td>
</tr>
<tr>
<td>2020-08-03</td>
<td>2</td>
</tr>
<tr>
<td>2020-07-31</td>
<td>1</td>
</tr>
<tr>
<td>2020-07-27</td>
<td>1</td>
</tr>
<tr>
<td>2020-07-20</td>
<td>1</td>
</tr>
<tr>
<td>2020-07-15</td>
<td>2</td>
</tr>
<tr>
<td>2020-07-14</td>
<td>2</td>
</tr>
<tr>
<td>2020-07-13</td>
<td>1</td>
</tr>
<tr>
<td>2020-07-09</td>
<td>1</td>
</tr>
<tr>
<td>2020-07-03</td>
<td>2</td>
</tr>
<tr>
<td>2020-07-01</td>
<td>5</td>
</tr>
<tr>
<td>2020-06-30</td>
<td>4</td>
</tr>
<tr>
<td>2020-06-23</td>
<td>2</td>
</tr>
<tr>
<td>2020-06-19</td>
<td>2</td>
</tr>
<tr>
<td>2020-06-18</td>
<td>4</td>
</tr>
<tr>
<td>2020-06-16</td>
<td>1</td>
</tr>
<tr>
<td>2020-06-15</td>
<td>1</td>
</tr>
<tr>
<td>2020-06-11</td>
<td>1</td>
</tr>
<tr>
<td>2020-06-10</td>
<td>1</td>
</tr>
<tr>
<td>2020-06-05</td>
<td>1</td>
</tr>
<tr>
<td>2020-06-04</td>
<td>1</td>
</tr>
<tr>
<td>2020-05-29</td>
<td>1</td>
</tr>
<tr>
<td>2020-05-26</td>
<td>1</td>
</tr>
<tr>
<td>2020-05-25</td>
<td>2</td>
</tr>
<tr>
<td>2020-05-21</td>
<td>2</td>
</tr>
<tr>
<td>2020-05-20</td>
<td>2</td>
</tr>
<tr>
<td>2020-05-15</td>
<td>1</td>
</tr>
<tr>
<td>2020-05-14</td>
<td>1</td>
</tr>
<tr>
<td>2020-05-11</td>
<td>6</td>
</tr>
<tr>
<td>2020-05-09</td>
<td>1</td>
</tr>
<tr>
<td>2020-05-08</td>
<td>9</td>
</tr>
<tr>
<td>2020-05-07</td>
<td>1</td>
</tr>
<tr>
<td>2020-05-06</td>
<td>1</td>
</tr>
<tr>
<td>2020-05-05</td>
<td>1</td>
</tr>
<tr>
<td>2020-05-03</td>
<td>1</td>
</tr>
<tr>
<td>2020-04-30</td>
<td>1</td>
</tr>
<tr>
<td>2020-04-29</td>
<td>8</td>
</tr>
<tr>
<td>2020-04-28</td>
<td>3</td>
</tr>
<tr>
<td>2020-04-22</td>
<td>2</td>
</tr>
<tr>
<td>2020-04-21</td>
<td>2</td>
</tr>
<tr>
<td>2020-04-20</td>
<td>1</td>
</tr>
<tr>
<td>2020-04-16</td>
<td>1</td>
</tr>
<tr>
<td>2020-04-15</td>
<td>1</td>
</tr>
<tr>
<td>2020-04-14</td>
<td>2</td>
</tr>
<tr>
<td>2020-04-09</td>
<td>1</td>
</tr>
<tr>
<td>2020-04-07</td>
<td>3</td>
</tr>
<tr>
<td>2020-04-06</td>
<td>3</td>
</tr>
<tr>
<td>2020-04-02</td>
<td>3</td>
</tr>
<tr>
<td>2020-04-01</td>
<td>5</td>
</tr>
<tr>
<td>2020-03-30</td>
<td>2</td>
</tr>
<tr>
<td>2020-03-27</td>
<td>1</td>
</tr>
<tr>
<td>2020-03-26</td>
<td>2</td>
</tr>
<tr>
<td>2020-03-23</td>
<td>1</td>
</tr>
<tr>
<td>2020-03-19</td>
<td>1</td>
</tr>
<tr>
<td>2020-03-18</td>
<td>2</td>
</tr>
<tr>
<td>2020-03-17</td>
<td>1</td>
</tr>
<tr>
<td>2020-03-16</td>
<td>2</td>
</tr>
<tr>
<td>2020-03-13</td>
<td>3</td>
</tr>
<tr>
<td>2020-03-10</td>
<td>1</td>
</tr>
<tr>
<td>2020-03-09</td>
<td>1</td>
</tr>
<tr>
<td>2020-03-06</td>
<td>1</td>
</tr>
<tr>
<td>2020-03-04</td>
<td>3</td>
</tr>
<tr>
<td>2020-03-02</td>
<td>2</td>
</tr>
<tr>
<td>2020-02-28</td>
<td>3</td>
</tr>
<tr>
<td>2020-02-27</td>
<td>1</td>
</tr>
<tr>
<td>2020-02-26</td>
<td>1</td>
</tr>
<tr>
<td>2020-02-20</td>
<td>1</td>
</tr>
<tr>
<td>2020-02-19</td>
<td>8</td>
</tr>
<tr>
<td>2020-02-18</td>
<td>1</td>
</tr>
<tr>
<td>2020-02-14</td>
<td>2</td>
</tr>
<tr>
<td>2020-02-13</td>
<td>2</td>
</tr>
<tr>
<td>2020-02-12</td>
<td>3</td>
</tr>
<tr>
<td>2020-02-11</td>
<td>7</td>
</tr>
<tr>
<td>2020-02-10</td>
<td>14</td>
</tr>
<tr>
<td>2020-02-07</td>
<td>2</td>
</tr>
<tr>
<td>2020-02-06</td>
<td>3</td>
</tr>
<tr>
<td>2020-02-05</td>
<td>1</td>
</tr>
<tr>
<td>2020-02-04</td>
<td>1</td>
</tr>
<tr>
<td>2020-02-03</td>
<td>10</td>
</tr>
<tr>
<td>2020-01-31</td>
<td>3</td>
</tr>
<tr>
<td>2020-01-30</td>
<td>2</td>
</tr>
<tr>
<td>2020-01-28</td>
<td>3</td>
</tr>
<tr>
<td>2020-01-24</td>
<td>3</td>
</tr>
<tr>
<td>2020-01-23</td>
<td>14</td>
</tr>
<tr>
<td>2020-01-22</td>
<td>3</td>
</tr>
<tr>
<td>2020-01-21</td>
<td>1</td>
</tr>
<tr>
<td>2020-01-20</td>
<td>2</td>
</tr>
<tr>
<td>2020-01-17</td>
<td>1</td>
</tr>
<tr>
<td>2020-01-16</td>
<td>3</td>
</tr>
<tr>
<td>2020-01-14</td>
<td>1</td>
</tr>
<tr>
<td>2020-01-09</td>
<td>5</td>
</tr>
<tr>
<td>2020-01-06</td>
<td>1</td>
</tr>
<tr>
<td>2020-01-03</td>
<td>1</td>
</tr>
<tr>
<td>2019-12-19</td>
<td>2</td>
</tr>
<tr>
<td>2019-12-18</td>
<td>2</td>
</tr>
<tr>
<td>2019-12-17</td>
<td>1</td>
</tr>
<tr>
<td>2019-12-16</td>
<td>3</td>
</tr>
<tr>
<td>2019-12-11</td>
<td>2</td>
</tr>
<tr>
<td>2019-12-10</td>
<td>3</td>
</tr>
<tr>
<td>2019-12-09</td>
<td>11</td>
</tr>
<tr>
<td>2019-12-06</td>
<td>3</td>
</tr>
<tr>
<td>2019-12-03</td>
<td>1</td>
</tr>
<tr>
<td>2019-12-02</td>
<td>4</td>
</tr>
<tr>
<td>2019-11-29</td>
<td>1</td>
</tr>
<tr>
<td>2019-11-28</td>
<td>2</td>
</tr>
<tr>
<td>2019-11-22</td>
<td>2</td>
</tr>
<tr>
<td>2019-11-14</td>
<td>2</td>
</tr>
<tr>
<td>2019-11-07</td>
<td>3</td>
</tr>
<tr>
<td>2019-11-06</td>
<td>26</td>
</tr>
<tr>
<td>2019-11-04</td>
<td>1</td>
</tr>
<tr>
<td>2019-11-01</td>
<td>1</td>
</tr>
<tr>
<td>2019-10-31</td>
<td>1</td>
</tr>
<tr>
<td>2019-10-23</td>
<td>1</td>
</tr>
<tr>
<td>2019-10-22</td>
<td>2</td>
</tr>
<tr>
<td>2019-10-21</td>
<td>1</td>
</tr>
<tr>
<td>2019-10-17</td>
<td>2</td>
</tr>
<tr>
<td>2019-10-09</td>
<td>1</td>
</tr>
<tr>
<td>2019-10-08</td>
<td>1</td>
</tr>
<tr>
<td>2019-10-04</td>
<td>2</td>
</tr>
<tr>
<td>2019-10-03</td>
<td>1</td>
</tr>
<tr>
<td>2019-09-19</td>
<td>2</td>
</tr>
<tr>
<td>2019-09-16</td>
<td>1</td>
</tr>
<tr>
<td>2019-09-12</td>
<td>1</td>
</tr>
<tr>
<td>2019-09-10</td>
<td>1</td>
</tr>
<tr>
<td>2019-09-06</td>
<td>3</td>
</tr>
<tr>
<td>2019-09-05</td>
<td>1</td>
</tr>
<tr>
<td>2019-09-04</td>
<td>1</td>
</tr>
<tr>
<td>2019-09-03</td>
<td>1</td>
</tr>
<tr>
<td>2019-09-02</td>
<td>1</td>
</tr>
<tr>
<td>2019-08-29</td>
<td>2</td>
</tr>
<tr>
<td>2019-08-26</td>
<td>1</td>
</tr>
<tr>
<td>2019-08-22</td>
<td>2</td>
</tr>
<tr>
<td>2019-08-21</td>
<td>1</td>
</tr>
<tr>
<td>2019-08-16</td>
<td>1</td>
</tr>
<tr>
<td>2019-08-13</td>
<td>2</td>
</tr>
<tr>
<td>2019-08-06</td>
<td>1</td>
</tr>
<tr>
<td>2019-08-01</td>
<td>2</td>
</tr>
<tr>
<td>2019-07-31</td>
<td>1</td>
</tr>
<tr>
<td>2019-07-30</td>
<td>1</td>
</tr>
<tr>
<td>2019-07-29</td>
<td>1</td>
</tr>
<tr>
<td>2019-07-26</td>
<td>1</td>
</tr>
<tr>
<td>2019-07-22</td>
<td>3</td>
</tr>
<tr>
<td>2019-07-17</td>
<td>1</td>
</tr>
<tr>
<td>2019-07-15</td>
<td>2</td>
</tr>
<tr>
<td>2019-07-12</td>
<td>2</td>
</tr>
<tr>
<td>2019-07-11</td>
<td>3</td>
</tr>
<tr>
<td>2019-07-10</td>
<td>1</td>
</tr>
<tr>
<td>2019-06-27</td>
<td>1</td>
</tr>
<tr>
<td>2019-06-11</td>
<td>1</td>
</tr>
<tr>
<td>2019-06-10</td>
<td>1</td>
</tr>
<tr>
<td>2019-06-04</td>
<td>1</td>
</tr>
<tr>
<td>2019-05-29</td>
<td>4</td>
</tr>
<tr>
<td>2019-05-28</td>
<td>1</td>
</tr>
<tr>
<td>2019-05-24</td>
<td>4</td>
</tr>
<tr>
<td>2019-05-23</td>
<td>2</td>
</tr>
<tr>
<td>2019-05-21</td>
<td>1</td>
</tr>
<tr>
<td>2019-05-15</td>
<td>1</td>
</tr>
<tr>
<td>2019-05-08</td>
<td>1</td>
</tr>
<tr>
<td>2019-05-07</td>
<td>1</td>
</tr>
<tr>
<td>2019-05-03</td>
<td>1</td>
</tr>
<tr>
<td>2019-05-02</td>
<td>2</td>
</tr>
<tr>
<td>2019-05-01</td>
<td>5</td>
</tr>
<tr>
<td>2019-04-30</td>
<td>13</td>
</tr>
<tr>
<td>2019-04-29</td>
<td>1</td>
</tr>
<tr>
<td>2019-04-24</td>
<td>1</td>
</tr>
<tr>
<td>2019-04-23</td>
<td>3</td>
</tr>
<tr>
<td>2019-04-17</td>
<td>1</td>
</tr>
<tr>
<td>2019-04-10</td>
<td>2</td>
</tr>
<tr>
<td>2019-04-09</td>
<td>1</td>
</tr>
<tr>
<td>2019-04-05</td>
<td>1</td>
</tr>
<tr>
<td>2019-04-04</td>
<td>1</td>
</tr>
<tr>
<td>2019-04-03</td>
<td>2</td>
</tr>
<tr>
<td>2019-04-02</td>
<td>2</td>
</tr>
<tr>
<td>2019-04-01</td>
<td>2</td>
</tr>
<tr>
<td>2019-03-29</td>
<td>8</td>
</tr>
<tr>
<td>2019-03-28</td>
<td>3</td>
</tr>
<tr>
<td>2019-03-27</td>
<td>1</td>
</tr>
<tr>
<td>2019-03-26</td>
<td>2</td>
</tr>
<tr>
<td>2019-03-25</td>
<td>5</td>
</tr>
<tr>
<td>2019-03-22</td>
<td>3</td>
</tr>
<tr>
<td>2019-03-20</td>
<td>1</td>
</tr>
<tr>
<td>2019-03-19</td>
<td>2</td>
</tr>
<tr>
<td>2019-03-18</td>
<td>1</td>
</tr>
<tr>
<td>2019-03-15</td>
<td>1</td>
</tr>
</tbody>
</table>
</body>
</html>
【讨论】:
但是如果他的叔叔禁止使用 css 怎么办?以上是关于使用 moment.js 设置可变日期值的主要内容,如果未能解决你的问题,请参考以下文章