PHP code example of axetools / dateutil

1. Go to this page and download the library: Download axetools/dateutil 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/ */

    

axetools / dateutil example snippets



// The first Monday of the Month of September for the current year
$labor_day = DateTimeUtil::RelativeDateTime(9, DayOfWeek::MONDAY, Week::FIRST);

// Get Christmas day, December 25th for the current year
$christmas_day = DateTimeUtil::AbsoluteDateTime(12, 25);

// Get the last day of April for 2022
$last_day_april = DateTimeUtil::AbsoluteDateTime(4, DateTimeUtil::RELATIVE_LAST_DAY);

// Get the last day of the current month
$last_day_this_month = DateTimeUtil::AbsoluteDateTime(null, DateTimeUtil::RELATIVE_LAST_DAY);

// Get an array of Holiday objects for the US Federal Holidays from 2001
$holidays_2001 = DateTimeUtil::usFederalHolidays(2001);

// Determine if a reference datetime is between a start and end datetime
$start = Datetime::createFromFormat('Y-m-d', '2022-01-01');
$end = Datetime::createFromFormat('Y-m-d', '2022-01-05');
$reference = Datetime::createFromFormat('Y-m-d', '2022-01-03');
$is_between = DateTimeUtil::isBetween($start, $end, $reference);

// true