如果可以的话,我会使用 PHP,只需将日期列表返回给beforeShowDay
DatePicker 的方法。
当您将数据库中的日期添加到列表中时,也可以使用strtotime($Date, '1 day')
添加第二天。
编辑:
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT distinct Date, DATE_ADD(Date, INTERVAL 31 DAY) as Tomorrow from Table";
$result = $mysqli->query($query);
$Dates = array();
/* numeric array */
while(($row = $result->fetch_array(MYSQLI_NUM)) !== null)
{
//$Tomorrow = strtotime('1 day', $row['Date']);
$Tomorrow = $row['Tomorrow'];
if(!in_array($row['Date'], $Dates)) $Dates[] = $row['Date'];
if(!in_array($Tomorrow, $Dates)) $Dates[] = $Tomorrow;
}
/* free result set */
$result->free();
/* close connection */
$mysqli->close();
header('content-type: application/json');
die(json_encode(array('Dates' => $Dates)));