修复日期显示不一致问题:1)在index.php中使用本地时区获取日期字符串,避免toISOString()导致的时区偏差;2)在vip.php中同样修改默认预约日期的获取方式
This commit is contained in:
@@ -437,13 +437,20 @@ $packages_json = json_encode(array_map(function($package) {
|
||||
for (let dayOffset = 0; dayOffset < 7; dayOffset++) {
|
||||
const date = new Date(pageStartMonday);
|
||||
date.setDate(pageStartMonday.getDate() + dayOffset);
|
||||
const dateStr = date.toISOString().split('T')[0];
|
||||
// 确保使用本地时区获取日期字符串
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const dateStr = `${year}-${month}-${day}`;
|
||||
const dateDisplay = `${date.getMonth() + 1}/${date.getDate()}`;
|
||||
const weekday = ['日', '一', '二', '三', '四', '五', '六'][date.getDay()];
|
||||
|
||||
// 获取今天的日期字符串用于比较
|
||||
const today = new Date();
|
||||
const todayStr = today.toISOString().split('T')[0];
|
||||
const todayYear = today.getFullYear();
|
||||
const todayMonth = String(today.getMonth() + 1).padStart(2, '0');
|
||||
const todayDay = String(today.getDate()).padStart(2, '0');
|
||||
const todayStr = `${todayYear}-${todayMonth}-${todayDay}`;
|
||||
const isToday = dateStr === todayStr;
|
||||
|
||||
// 获取预约数量
|
||||
|
||||
@@ -922,7 +922,11 @@ try {
|
||||
document.getElementById('booking_car_number').value = carNumber || '';
|
||||
|
||||
// 设置默认预约日期为今天
|
||||
document.getElementById('booking_date').value = new Date().toISOString().split('T')[0];
|
||||
const today = new Date();
|
||||
const year = today.getFullYear();
|
||||
const month = String(today.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(today.getDate()).padStart(2, '0');
|
||||
document.getElementById('booking_date').value = `${year}-${month}-${day}`;
|
||||
|
||||
// 清空其他字段
|
||||
document.getElementById('booking_time_slot').value = '';
|
||||
|
||||
Reference in New Issue
Block a user