I have two datetime fields and I would like to know the difference between them. I'm developing in Php Gtk, so the functions have to be of the lowest possible level.
I have two datetime fields and I would like to know the difference between them. I'm developing in Php Gtk, so the functions have to be of the lowest possible level.
One of the ways to do this object-oriented, is to use the DateTime class, it has the diff method that returns a DateInterval object, which represents the interval between two distinct dates:
Following the example dates:
$data1 = new DateTime( '2013-12-11' );
$data2 = new DateTime( '1994-04-17' );
$intervalo = $data1->diff( $data2 );
echo "Intervalo é de {$intervalo->y} anos, {$intervalo->m} meses e {$intervalo->d} dias";