Mactos_Cohen Posted December 5, 2012 at 09:43 AM Report #485834 Posted December 5, 2012 at 09:43 AM (edited) Ola, Caros amigos. Preciso de uma ajuda não sei como somar mese, exemplo <?php $checkin = '2008-05-05'; $checkout = '2008-06-05'; $data1 = strtotime("$checkin_cin"); $data2 = strtotime("$checkout_cin"); $resultado = $dat2 - $dat1; $resultado_final = $res / 86400; echo $resultado_final ; ?> mas ele assim me da numero de dias que é 31 eu preciso numero de meses nesse caso seria 1 alguém ai... Obrigado Edited December 5, 2012 at 10:46 AM by brunoais geshi
MASNathan Posted December 5, 2012 at 09:53 AM Report #485835 Posted December 5, 2012 at 09:53 AM isso foi testado? é que cada variável tem um nome diferente
HappyHippyHippo Posted December 5, 2012 at 10:13 AM Report #485839 Posted December 5, 2012 at 10:13 AM depois de corrigires o teu código como foi referido pelo @MASNathen, dá uma vista de olhos aqui: http://php.net/manual/en/datetime.diff.php IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Mactos_Cohen Posted December 5, 2012 at 02:24 PM Author Report #485865 Posted December 5, 2012 at 02:24 PM <?php $checkin = '2008-05-05'; $checkout = '2008-06-05'; $data1 = strtotime("$checkin"); $data2 = strtotime("$checkout"); $resultado = $dat2 - $dat1; $resultado_final = $res / 86400; echo $resultado_final ; ?> Obrigado MASNathan dei conta do erro. mas ele assim me da numero de dias que é 31 eu preciso numero de meses nesse caso seria 1
HappyHippyHippo Posted December 5, 2012 at 02:45 PM Report #485867 Posted December 5, 2012 at 02:45 PM depois de corrigires o teu código como foi referido pelo @MASNathen, dá uma vista de olhos aqui: http://php.net/manual/en/datetime.diff.php IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Mactos_Cohen Posted December 5, 2012 at 08:14 PM Author Report #485961 Posted December 5, 2012 at 08:14 PM <?php $checkin = new DateTime(date('2011-11-09')); $checkout = new DateTime(date('2011-12-09')); echo $resultado = $checkin->diff($checkout)->m; ?> Ok obrigado a todos, fiz assim e funcionou.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now