Fix countdown to show full days by setting end time to end of day

- Always set sale end time to 23:59:59 of target date
- Ensures proper day counting regardless of time selected in admin
- July 11 to July 18 should now show 7 days instead of 2
This commit is contained in:
DaX
2025-07-11 12:37:35 +02:00
parent eb7cb2d94f
commit 04b7ab9b55

View File

@@ -31,8 +31,13 @@ export function SaleCountdown({ hasActiveSale, maxSalePercentage = 5, saleEndDat
let targetDate: Date; let targetDate: Date;
if (saleEndDate) { if (saleEndDate) {
// Use the sale end date from admin - ensure proper timezone handling // Use the sale end date from admin
targetDate = new Date(saleEndDate); targetDate = new Date(saleEndDate);
// Always set to end of day for proper countdown display
const saleDate = new Date(saleEndDate);
targetDate = new Date(saleDate.getFullYear(), saleDate.getMonth(), saleDate.getDate(), 23, 59, 59, 999);
console.log('Sale end date from DB:', saleEndDate); console.log('Sale end date from DB:', saleEndDate);
console.log('Parsed target date:', targetDate); console.log('Parsed target date:', targetDate);
console.log('Current time:', now); console.log('Current time:', now);