PHP number of days for each year between two dates
Posted: 2023-10-10 09:07
PHP
how to calculate interest by number of days with a different rate for each year, example:
start date 2021-05-12
end date 2023-09-24
interest rate:
(a) 2021 = 3.50%
(b) 2022 = 2.94%
(c) 2023 = 4.87%
progress:
days to calculate:
from 2021-05-12 (start) to 2021-12-31 = x
from 2022-01-01 to 2022-12-31 = y
from 2023-01-01 to 2023-09-24 (end) = z
pd1 = (a / 365) * x
pd2 = (b / 365) * y
pd3 = (c / 365) * z
total interest = (pd1 + pd2 + pd3)
in PHP
anyone want to help me?
(forgive me, I'm a 62 year old idiot)
many thanks
how to calculate interest by number of days with a different rate for each year, example:
start date 2021-05-12
end date 2023-09-24
interest rate:
(a) 2021 = 3.50%
(b) 2022 = 2.94%
(c) 2023 = 4.87%
progress:
days to calculate:
from 2021-05-12 (start) to 2021-12-31 = x
from 2022-01-01 to 2022-12-31 = y
from 2023-01-01 to 2023-09-24 (end) = z
pd1 = (a / 365) * x
pd2 = (b / 365) * y
pd3 = (c / 365) * z
total interest = (pd1 + pd2 + pd3)
in PHP
anyone want to help me?
(forgive me, I'm a 62 year old idiot)
many thanks