Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal, bem.. tenho um sistema de boleto bancario que gera um carnê em 11 vezes com datas de30 a dias.
Bem o loop ele pega a data atual e calcula +30dias pra gerar o boleto.
Agora tou com uma duvida de colocar uma caixa de texto(Var $datavenc) e o loop calcular apartir da data informada..
más nao tou conseguindo raciocinar para alteração no codigo.
por favor me ajudem, desde já agradeço muito a ajuda de voces.
for($i = 0, $meses = 1 ;$i < $parcelas; $i++, $meses++){
$dadosboleto["data_vencimento"] = date("d/m/Y", strtotime("now +".$meses." months"));Eu faria usando a classe DateTime
Podendo inserir a data de início, o tempo de intervalo e o formato de saída.
<?php
$current_date = new DateTime( ); // data e hora atual
$current_date->add( new DateInterval( 'P30D' ) );
echo $current_date->format( 'Y-m-d H:i:s' ); // data e hora final
DateInterval::__construct
>
An interval specification.
The format starts with the letter P, for "period." Each duration period is represented by an integer value followed by a period designator. If the duration contains time elements, that portion of the specification is preceded by the letterT.
Period Designator Description Y years M months D days W weeks. These get converted into days, so can not be combined with D. H hours M minutes S secondsHere are some simple examples. Two days is P2D. Two seconds is PT2S. Six years and five minutes is P6YT5M.
****
Note****:
The unit types must be entered from the largest scale unit on the left to the smallest scale unit on the right. So years before months, months before days, days before minutes, etc. Thus one year and four days must be represented as P1Y4D, not P4D1Y.
The specification can also be represented as a date time. A sample of one year and four days would beP0001-00-04T00:00:00. But the values in this format can not exceed a given period's roll-over-point (e.g. 25 hours is invalid).
These formats are based on the » ISO 8601 duration specification.
Dellacurtais, muito obrigado pela sua ajuda.
tentei programar desse jeito más não consegui, por falta de conhecimentos mesmo..
consegui apenas com o strotime =\
tem como fazer com o strotime?
trabalhe com timestamp se torna mais facil manipular datas..
exemplo:
$Inicio = time(); time pega exatamente a data atual ou $inicio = mktime(); o mktime vc faz um timestamp de uma da especifica, para saber usar pega no php.net
http://br.php.net/mktime
depois um time de 30 dias:
$Proximo = 30*86400;
ai faz um loop mais ou menos assim:
terá uma array com 12 timestamp, basta transformar para data!
pequena correção::