Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # site referencia : http://www.rafaeltheodoro.com.br/php/funcoes-para-somar-dias-meses-ou-anos-em-datas/
- # função fazer a soma na data atual do servidor
- strftime('%d/%m/%Y', strtotime('+3 days'));
- strftime('%d/%m/%Y', strtotime('+3 months'));
- strftime('%d/%m/%Y', strtotime('+3 years'));
- # função quando sua data é um Date, Date Time ou um Timestamp vindo de um banco de dados
- function makeDateTime($date, $days=0, $mounths=0, $years=0)
- {
- $date = date('d/m/Y', strtotime($date));
- $date = explode("/", $date);
- return date('d/m/Y', mktime(0, 0, 0, $date[1] + $mounths, $date[0] + $days, $date[2] + $years) );
- }
- # utilizando a função abaixo Se sua data é uma STRING:
- function makeDateString($date, $days=0, $mounths=0, $years=0)
- {
- $date = explode("/", $date);
- return date('d/m/Y', mktime(0, 0, 0, $date[1] + $mounths, $date[0] + $days, $date[2] + $years) );
- }
Advertisement
Add Comment
Please, Sign In to add comment