vendredi 25 mai 2018

Show number depending on date

I need help to understand what way to use to make function work depending on current day.

$dateOne = 2018-01-24

$dateTwo = 2018-07-24

$full_amount= 10000

$amountOne = 2500

$amountTwo = 416

$frequency = 2(months)

What I have now:

if (date("Y-m-d") >= $dateTwo) { 
        return $amountOne + $amountTwo;
    } elseif (date("Y-m-d") >= $dateTwo) { 
        return $amountOne;
    } else {
        return 0;
    }

When current date >= $dateTwo I need to return $amountOne + $amountTwo but every 2 months ($frequency) after $dateTwo it need to count plus one more $amountTwo and if it like 4 months ($frequency x 2) plus $amountTwo 2 times.

In actual my users have some amount that they receive during some exact period partially. (you will have 10000 at all, but we will give it to you like $amountTwo parts every $frequency months until you get full amount (10000) )

if current date >= $dateOne + $frequency he will receive $amountOne + $amountTwo + $amountTwo. And it should work on what exact day today.

Hope I explained well, bc it can look a bit complicated to understand.

Aucun commentaire:

Enregistrer un commentaire