1 date.class.inc public BackdropDateTime::toArray($force = FALSE)

Returns all standard date parts in an array.

Will return '' for parts in which it lacks granularity.

Parameters

bool $force: Whether or not to limit the granularity. Defaults to FALSE.

Return value

array: An array of formatted date part values, keyed by date parts.

File

core/includes/date.class.inc, line 632

Class

BackdropDateTime
Extends PHP DateTime class for use with Backdrop.

Code

public function toArray($force = FALSE) {
  return array(
    'year' => $this->format('Y', $force),
    'month' => $this->format('n', $force),
    'day' => $this->format('j', $force),
    'hour' => intval($this->format('H', $force)),
    'minute' => intval($this->format('i', $force)),
    'second' => intval($this->format('s', $force)),
    'timezone' => $this->format('e', $force),
  );
}