DateRange
        DateRange.php
                :
        26
                
    
                                Final
                
        
        
                Immutable date range representation where left bound is inclusive, right bound is exclusive.
The following example range contains only one day:
$range = new DateRange(new DateTimeImmutable('2020-01-01'), new DateTimeImmutable('2020-01-02'));
    Methods¶
                
__construct()
            ¶
    
        
        DateRange.php
                :
        38
                
    
        | 
                     | 
                
                    
                     | 
            
Parameters
| Name | Type | Default value | Description | 
|---|---|---|---|
| $start | DateTimeInterface | - | 
                                                         Left bound of the range (inclusive)  | 
                
| $end | DateTimeInterface | - | 
                                                         Right bound of the range (exclusive)  | 
                
Tags
                
__toString()
            ¶
    
        
        DateRange.php
                :
        109
                
    
        Converts date range to string representation.
| 
                     | 
                
                    
                     | 
            
Example output: [2024-01-01T00:00:00+00:00 - 2024-01-02T00:00:00+00:00].
Return values
string
                
contains()
            ¶
    
        
        DateRange.php
                :
        75
                
    
        Checks if given date is within the range.
| 
                     | 
                
                    
                     | 
            
Parameters
| Name | Type | Default value | Description | 
|---|---|---|---|
| $dateTime | DateTimeInterface | - | - | 
Return values
bool
                
getEndDate()
            ¶
    
        
        DateRange.php
                :
        67
                
    
        Returns right bound of the range (exclusive).
| 
                     | 
                
                    
                     | 
            
Return values
DateTimeInterface
                
getStartDate()
            ¶
    
        
        DateRange.php
                :
        59
                
    
        Returns left bound of the range (inclusive).
| 
                     | 
                
                    
                     | 
            
Return values
DateTimeInterface
                
toDatePeriod()
            ¶
    
        
        DateRange.php
                :
        95
                
    
        Converts date range (non-discrete value) to date period (discrete value) using given interval (optional, P1D used as default value).
| 
                     | 
                
                    
                     | 
            
Typical use case is to iterate over all the recurring the dates within range. For example:
$period = $range->toDatePeriod(new DateInterval('P1W'));
foreach ($period as $date) {
    echo $date->format('Y-m-d')."\n";
}
    Parameters
| Name | Type | Default value | Description | 
|---|---|---|---|
| $interval | DateInterval|null | null | - | 
Return values
DatePeriod