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:
@@ -31,8 +31,13 @@ export function SaleCountdown({ hasActiveSale, maxSalePercentage = 5, saleEndDat
|
||||
let targetDate: Date;
|
||||
|
||||
if (saleEndDate) {
|
||||
// Use the sale end date from admin - ensure proper timezone handling
|
||||
// Use the sale end date from admin
|
||||
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('Parsed target date:', targetDate);
|
||||
console.log('Current time:', now);
|
||||
|
||||
Reference in New Issue
Block a user