Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Laravel 4.x Carbon Class

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 106
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: