1.20.x date.class.inc public BackdropDateTime::format($format, $force = FALSE)

Returns date formatted according to given format.

Overrides base format function, formats this date according to its available granularity, unless $force'ed not to limit to granularity.

@TODO Add translation into this so translated names will be provided.

Parameters

string $format: A date format string.

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

Return value

string|false: Returns the formatted date string on success or FALSE on failure.

File

includes/date.class.inc, line 231

Class

BackdropDateTime
Extends PHP DateTime class for use with Backdrop.

Code

public function format($format, $force = FALSE) {
  // If there are errors, formatting will likely not succeed. Return FALSE.
  if (!empty($this->errors)) {
    return FALSE;
  }
  return parent::format($force ? $format : date_limit_format($format, $this->granularity));
}