Using Carbon to manipulate date and time on Laravel
How to use a TimeDate API
Laravel comes with some awesome stuff, including Carbon – a PHP API Extension for DateTime – out-of-the-box. It can be used to easily manipulate dates. For instance, if you have 1995-01-30, which is Y-m-d format, you can easily mutate it to 30/01/1995using Carbon. It is as simple as the following:
Laravel allows we to retrieve stuff from the database directly as a Carbon instance. It has, by default, created_at and modified_at as Carbon instances. We can add new fields by creating an array php $dates with the fields. If I want to retrieve everything from the day field as a Carbon instance, I just have to put in on the array.
Carbon has many other features and you can check them all here. :)
Comments