PHP code example of omitobisam / carbonate

1. Go to this page and download the library: Download omitobisam/carbonate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

omitobisam / carbonate example snippets


$result = $mydate->everyWeekendDays($enddate);

//
/*
* Result - A collection of dates in the weekend
*/
//

Illuminate\Support\Collection Object ( [items:protected] => Array ( 
[0] => Carbonate\Carbonate Object ( [date] => 2017-09-02 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) 
[1] => Carbonate\Carbonate Object ( [date] => 2017-09-03 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) 
[2] => Carbonate\Carbonate Object ( [date] => 2017-09-09 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC )  
.......

// Verify if the last Carbon instance is actually weekend

$mydate->everyWeekendDays($enddate)->last()->isWeekend();

Carbonate::stringify($mydate->everyWeekendDays($enddate));

//
/*
* Result - A collection of dates in the weekends as string
*/
//

Illuminate\Support\Collection Object ( [items:protected] => Array ( 
[0] => 2017-09-02 00:00:00 
[1] => 2017-09-03 00:00:00 
[2] => 2017-09-09 00:00:00 
[3] => 2017-09-10 00:00:00 
[4] => 2017-09-16 00:00:00 
[5] => 2017-09-17 00:00:00 
[6] => 2017-09-23 00:00:00 
[7] => 2017-09-24 00:00:00 
[8] => 2017-09-30 00:00:00 
[9] => 2017-10-01 00:00:00 
[10] => 2017-10-07 00:00:00 
[11] => 2017-10-08 00:00:00 
[12] => 2017-10-14 00:00:00 
[13] => 2017-10-15 00:00:00 
[14] => 2017-10-21 00:00:00 
[15] => 2017-10-22 00:00:00 
[16] => 2017-10-28 00:00:00 
[17] => 2017-10-29 00:00:00 ) )


Carbonate::carbonate(['today', 'tomorrow', '2017-10-30']);


Illuminate\Support\Collection Object ( [items:protected] => Array ( 
[0] => Carbonate\Carbonate Object ( [date] => 2017-10-21 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin ) 
[1] => Carbonate\Carbonate Object ( [date] => 2017-10-22 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin ) 
[2] => Carbonate\Carbonate Object ( [date] => 2017-10-30 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin ) ) )


$mydate->thisMonth();
$mydate->getDatesOfDaysInMonth(['Monday', 'Saturday']);
$mydate->everyWeekDays();
$mydate->everyDay('Monday');
$mydate->random(2);
$mydate->randomOne();
$mydate->anyMonday();
$mydate->anyTuesday();
$mydate->anyWednesday();
$mydate->anyThursday();
$mydate->anyFriday();
$mydate->anySaturday();
$mydate->anySunday();
$mydate->any();
$mydate->anyOne('Monday');
$mydate->stringify([Carbonate::now(), Carbonate::now()->addDay(1)]);
$mydate->carbonate(['today', 'tomorrow']);
$mydate->weekends(Carbonate::now()->addDay(7));