1
Guys I’m putting together a script on php
which will be executed on the first day of each month, generating a receivable based on a value of 120.00. That is to say on the first day of each month he creates an account of 120.00.
The problem is that if the customer starts using the service on the 15th or any other day, he has to pay a fee proportional to the days he used. That’s simple, I divide the 120 by the days of the month and then multiply by the days used. The problem is I have no idea how to recover used days.
If anyone can help me.
Follow the variables with the data I recover from BD.
$valor_mensalidade = 120;
$data_inicio = "2016-06-15";
Well, it didn’t work out so well. See well put the following value ($dateInit = '2016-06-01';) being that today is days 09 correct, so the value in $result had to be 36,00.
– Hugo Borges
This is 36.. http://pastebin.com/R3UwWaEM
– Fábio
for me this returning 4. $valueMonth = 120; $dateInit = '2016-06-01'; $totalDays = date(’t', strtotime($dateInit)); $used = date(’d, strtotime($dateInit)); $result = ($valueMonth/$totalDays)*$used;
 result; echo $ $result;
– Hugo Borges
If the date init is 01, you do not need to do accounts :) The date init is the date of user registration..
– Fábio
I made confusion hahahah, it worked here thank you very much
– Hugo Borges
how would I have a variable and start and end? ie for it to calculate in a date danger?
– Hugo Borges