Wraps DateTime().
This class wraps the PHP DateTime class with more flexible initialization parameters, allowing a date to be created from an existing date object, a timestamp, a string with an unknown format, a string with a known format, or an array of date parts. It also adds an errors array and a __toString() method to the date object.
This class is less lenient than the DateTime class. It changes the default behavior for handling date values like '2011-00-00'. The DateTime class would convert that value to '2010-11-30' and report a warning but not an error. This extension treats that as an error.
As with the DateTime class, a date object may be created even if it has errors. It has an errors array attached to it that explains what the errors are. This is less disruptive than allowing datetime exceptions to abort processing. The calling script can decide what to do about errors using hasErrors() and getErrors().
Hierarchy
- class \Drupal\Component\Datetime\DateTimePlus uses ToStringTrait
File
- core/lib/Drupal/Component/Datetime/DateTimePlus.php, line 26
Namespace
Drupal\Component\Datetime
Members
Name | Modifiers | Type | Description |
---|---|---|---|
DateTimePlus::$dateParts | protected static | property | An array of possible date parts. |
DateTimePlus::$dateTimeObject | protected | property | The DateTime object. |
DateTimePlus::$errors | protected | property | An array of errors encountered when creating this date. |
DateTimePlus::$inputFormatAdjusted | protected | property | The prepared format, if provided. |
DateTimePlus::$inputFormatRaw | protected | property | The value of the format passed to the constructor. |
DateTimePlus::$inputTimeAdjusted | protected | property | The prepared time, without timezone, for this date. |
DateTimePlus::$inputTimeRaw | protected | property | The value of the time value passed to the constructor. |
DateTimePlus::$inputTimeZoneAdjusted | protected | property | The prepared timezone object used to construct this date. |
DateTimePlus::$inputTimeZoneRaw | protected | property | The value of the timezone passed to the constructor. |
DateTimePlus::$langcode | protected | property | The value of the language code passed to the constructor. |
DateTimePlus::arrayToISO | public static | function | Creates an ISO date from an array of values. |
DateTimePlus::checkArray | public static | function | Checks that arrays of date parts will create a valid date. |
DateTimePlus::checkErrors | public | function | Examines getLastErrors() to see what errors to report. |
DateTimePlus::createFromArray | public static | function | Creates a date object from an array of date parts. |
DateTimePlus::createFromDateTime | public static | function | Creates a date object from an input date object. |
DateTimePlus::createFromFormat | public static | function | Creates a date object from an input format. |
DateTimePlus::createFromTimestamp | public static | function | Creates a date object from timestamp input. |
DateTimePlus::datePad | public static | function | Pads date parts with zeros. |
DateTimePlus::diff | public | function | Returns the difference between two DateTimePlus objects. |
DateTimePlus::format | public | function | Formats the date for display. |
DateTimePlus::FORMAT | constant | ||
DateTimePlus::getErrors | public | function | Gets error messages. |
DateTimePlus::hasErrors | public | function | Detects if there were errors in the processing of this date. |
DateTimePlus::prepareArray | public static | function | Creates a complete array from a possibly incomplete array of date parts. |
DateTimePlus::prepareFormat | protected | function | Prepares the input format value. |
DateTimePlus::prepareTime | protected | function | Prepares the input time value. |
DateTimePlus::prepareTimezone | protected | function | Prepares the input timezone value. |
DateTimePlus::render | public | function | Renders the timezone name. Overrides ToStringTrait::render |
DateTimePlus::RFC7231 | constant | A RFC7231 Compliant date. | |
DateTimePlus::__call | public | function | Implements the magic __call method. |
DateTimePlus::__callStatic | public static | function | Implements the magic __callStatic method. |
DateTimePlus::__clone | public | function | Implements the magic __clone method. |
DateTimePlus::__construct | public | function | Constructs a date object set to a requested date and timezone. |
ToStringTrait::_die | protected | function | For test purposes, wrap die() in an overridable method. |
ToStringTrait::__toString | public | function | Implements the magic __toString() method. |
Please login to continue.