Drupal 8  8.0.2
DrupalDateTime Class Reference
Inheritance diagram for DrupalDateTime:

Public Member Functions

 __construct ($time= 'now', $timezone=NULL, $settings=array())
 
 format ($format, $settings=array())
 
- Public Member Functions inherited from DateTimePlus
 __construct ($time= 'now', $timezone=NULL, $settings=array())
 
 render ()
 
 __call ($method, $args)
 
 __clone ()
 
 checkErrors ()
 
 hasErrors ()
 
 getErrors ()
 
 format ($format, $settings=array())
 

Protected Member Functions

 prepareTimezone ($timezone)
 
- Protected Member Functions inherited from DateTimePlus
 prepareTime ($time)
 
 prepareTimezone ($timezone)
 
 prepareFormat ($format)
 

Protected Attributes

 $formatTranslationCache
 
- Protected Attributes inherited from DateTimePlus
 $inputTimeRaw = ''
 
 $inputTimeAdjusted = ''
 
 $inputTimeZoneRaw = ''
 
 $inputTimeZoneAdjusted = ''
 
 $inputFormatRaw = ''
 
 $inputFormatAdjusted = ''
 
 $langcode = NULL
 
 $errors = array()
 
 $dateTimeObject = NULL
 

Additional Inherited Members

- Static Public Member Functions inherited from DateTimePlus
static createFromDateTime (\DateTime $datetime, $settings=array())
 
static createFromArray (array $date_parts, $timezone=NULL, $settings=array())
 
static createFromTimestamp ($timestamp, $timezone=NULL, $settings=array())
 
static createFromFormat ($format, $time, $timezone=NULL, $settings=array())
 
static __callStatic ($method, $args)
 
static arrayToISO ($array, $force_valid_date=FALSE)
 
static prepareArray ($array, $force_valid_date=FALSE)
 
static checkArray ($array)
 
static datePad ($value, $size=2)
 
- Data Fields inherited from DateTimePlus
const FORMAT = 'Y-m-d H:i:s'
 
const RFC7231 = 'D, d M Y H:i:s \G\M\T'
 
- Static Protected Attributes inherited from DateTimePlus
static $dateParts
 

Detailed Description

Extends DateTimePlus().

This class extends the basic component and adds in Drupal-specific handling, like translation of the format() method.

Static methods in base class can also be used to create DrupalDateTime objects. For example:

DrupalDateTime::createFromArray( array('year' => 2010, 'month' => 9, 'day' => 28) )

See Also
/Component/Datetime/DateTimePlus.php

Constructor & Destructor Documentation

__construct (   $time = 'now',
  $timezone = NULL,
  $settings = array() 
)

Constructs a date object.

Parameters
string$timeA date/input_time_adjusted string. Defaults to 'now'.
mixed$timezonePHP DateTimeZone object, string or NULL allowed. Defaults to NULL.
array$settings
  • validate_format: (optional) Boolean choice to validate the created date using the input format. The format used in createFromFormat() allows slightly different values than format(). Using an input format that works in both functions makes it possible to a validation step to confirm that the date created from a format string exactly matches the input. This option indicates the format can be used for validation. Defaults to TRUE.
  • langcode: (optional) Used to control the result of the format() method. Defaults to NULL.
  • debug: (optional) Boolean choice to leave debug values in the date object for debugging purposes. Defaults to FALSE.

References Drupal\languageManager().

Here is the call graph for this function:

Member Function Documentation

format (   $format,
  $settings = array() 
)

Overrides format().

Parameters
string$formatA format string using either PHP's date().
array$settings
  • timezone: (optional) String timezone name. Defaults to the timezone of the date object.
  • langcode: (optional) String two letter language code used to control the result of the format() method. Defaults to NULL.
Returns
string The formatted value of the date. Since the format may contain user input, this value should be escaped when output.

References DateTimePlus\$langcode, and t().

Referenced by DateElementBase\datetimeRangeYears(), and DateTimeIso8601\setDateTime().

Here is the call graph for this function:

Here is the caller graph for this function:

prepareTimezone (   $timezone)
protected

Overrides prepareTimezone().

Override basic component timezone handling to use Drupal's knowledge of the preferred user timezone.

Field Documentation

$formatTranslationCache
protected

Format string translation cache.


The documentation for this class was generated from the following file: