The Carbon class is inherited from the PHP DateTime class.
Example:
<?php
class Carbon extends \DateTime
{
// code here
}
?>
There are n number of situation when we want to get the 1 day or 2 days old data. For this we will do calculation on our query.But by using Carbon we will overcome such issues.
Example : Suppose we want to show the 2 days before data then for this
$twoDays = Carbon::now()->subDays(2);
and that data we will use in query and get the result.
For Minutes:
$date = Carbon::now()->addMinutes(5);
By this way we can use Carbon class in Laravel 4.x for solving complex date issue.
0 Comment(s)