You are here

function views_xml_backend_format_value in Views XML Backend 8

Returns a formatted date value.

Parameters

string $date: The date to convert.

string $format: The format to return.

Return value

string The formatted date value.

1 string reference to 'views_xml_backend_format_value'
Xml::getXpath in src/Plugin/views/query/Xml.php
Returns the XPath object for this query.

File

./views_xml_backend.module, line 110
Hook implementations for views_xml_backend.

Code

function views_xml_backend_format_value($date, $format) {
  $date = trim($date);

  // strtotime() does not handle year values.
  if (strlen($date) === 4 && (string) (int) $date === $date) {
    $date = 'January 1, ' . $date;
  }
  $timestamp = is_numeric($date) ? $date : strtotime($date);
  return date($format, $timestamp);
}