Let’s create a minimal example, to exemplify and show what happens:
In the first result that is the code print_r( \Carbon\Carbon::yesterday() );
Carbon\Carbon Object
(
[date] => 2018-01-14 00:00:00.000000
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
and in its result that is the code: print_r( \Carbon\Carbon::now() );
Carbon\Carbon Object
(
[date] => 2018-01-15 16:51:15.992829
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
the difference in hours of these two results by the code:
print_r( \Carbon\Carbon::now()->diffInHours( \Carbon\Carbon::yesterday() ) );
is the value of 40, because, the first result to arrive on the day 15 has 24 hours + 16 hours on Monday is the value of 40 hours difference.
On the other that the general code as minimum example:
print_r( \Carbon\Carbon::tomorrow() );
print_r( \Carbon\Carbon::now() );
print_r( \Carbon\Carbon::now()->diffInHours( \Carbon\Carbon::tomorrow() ) );
Exit:
Carbon\Carbon Object
(
[date] => 2018-01-16 00:00:00.000000
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
Carbon\Carbon Object
(
[date] => 2018-01-15 16:56:28.216548
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
has a difference of 7 hours because the day 15/01/2018 16:56:28.216548 to get to the day 16/01/2018 missing 7 o'clock.
To know if one date and time is greater than the other:
\Carbon\Carbon::setLocale('pt_BR');
$result = \Carbon\Carbon::create(2012, 9, 6, 0, 0, 0)
->gt( \Carbon\Carbon::create(2012, 9, 6, 0, 0, 0) );
var_dump($result); // saída bool(false)
did not work the answer?
– novic
@Virgilionovic sorry I missed the appointment.
– RFL