DateHelper
class DateHelper implements ProtectedContextAwareInterface (View source)
Date helpers for Eel contexts
Properties
| protected DatetimeFormatter | $datetimeFormatter | ||
| protected Service | $localizationService | 
Methods
Parse a date from string with a format to a DateTime object
Format a date (or interval) to a string with a given format
Format a date to a string with a given cldr format
Add an interval to a date and return a new DateTime object
Subtract an interval from a date and return a new DateTime object
All methods are considered safe
Details
        
                            DateTime
    parse(string $string, string $format)
        
    
    Parse a date from string with a format to a DateTime object
        
                            string
    format(int|string|DateTime|DateInterval $date, string $format)
        
    
    Format a date (or interval) to a string with a given format
See formatting options as in PHP date()
        
                            string
    formatCldr(int|string|DateTime $date, string $cldrFormat, null|string $locale = null)
        
    
    Format a date to a string with a given cldr format
        
                            DateTime
    create(string $time)
        
    
    Get a date object by given date or time format
Examples::
Date.create('2018-12-04') Date.create('first day of next year')
        
                            DateTime
    now()
        
    
    Get the current date and time
Examples::
Date.now().timestamp
        
                            DateTime
    today()
        
    
    Get the current date
        
                            DateTime
    add(DateTime $date, string|DateInterval $interval)
        
    
    Add an interval to a date and return a new DateTime object
        
                            DateTime
    subtract(DateTime $date, string|DateInterval $interval)
        
    
    Subtract an interval from a date and return a new DateTime object
        
                            DateInterval
    diff(DateTime $dateA, DateTime $dateB)
        
    
    Get the difference between two dates as a \DateInterval object
        
                            int
    dayOfMonth(DateTimeInterface $dateTime)
        
    
    Get the day of month of a date
        
                            int
    month(DateTimeInterface $dateTime)
        
    
    Get the month of a date
        
                            int
    year(DateTimeInterface $dateTime)
        
    
    Get the year of a date
        
                            int
    hour(DateTimeInterface $dateTime)
        
    
    Get the hour of a date (24 hour format)
        
                            int
    minute(DateTimeInterface $dateTime)
        
    
    Get the minute of a date
        
                            int
    second(DateTimeInterface $dateTime)
        
    
    Get the second of a date
        
                            bool
    allowsCallOfMethod(string $methodName)
        
    
    All methods are considered safe