İhtiyacı olan olursa diye hazırladığımı paylaşayım. Bu arada js bilmiyorum. Genelde hazır js kodları kullanıyorum. Sadece PHP biliyorum. Bunu verdiğiniz bilgilere dayanarak mantık yürüterek yaptım.
//BAŞLANGIÇ - TARİH DEĞERİNİ BELİRLE
//Bugünün tarihini belirle
//const Today = new Date("2023-09-23")
const TodayCurrentPrices = new Date();
//Günlerden Cumartesi(6) ise 1 gün düş
if (TodayCurrentPrices.getDay() === 6 )
{
//Tarihi "2023-09-23" formatından "23.09.2023" formatına çevir
function formatDate(date)
{
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()-1).padStart(2, "0");
return `${day}.${month}.${year}`;
}
}
//Günlerden Pazar(0) ise 2 gün düş
if (TodayCurrentPrices.getDay() === 0 )
{
//Tarihi "2023-09-23" formatından "23.09.2023" formatına çevir
function formatDate(date)
{
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()-2).padStart(2, "0");
return `${day}.${month}.${year}`;
}
}
//Günlerden Haftaiçi (1-2-3-4-5) ise olduğu gibi ver
if (TodayCurrentPrices.getDay() === 1 || TodayCurrentPrices.getDay() === 2 || TodayCurrentPrices.getDay() === 3 || TodayCurrentPrices.getDay() === 4 || TodayCurrentPrices.getDay() === 5 )
{
//Tarihi "2023-09-23" formatından "23.09.2023" formatına çevir
function formatDate(date)
{
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
return `${day}.${month}.${year}`;
}
}
const DateOptionTodayCurrentPrices = formatDate(TodayCurrentPrices);
//BİTİŞ - TARİH DEĞERİNİ BELİRLE