You are here

public function Sql::getDateField in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::getDateField()

Returns a Unix timestamp to database native timestamp expression.

Parameters

string $field: The query field that will be used in the expression.

bool $string_date: For certain databases, date format functions vary depending on string or numeric storage.

bool $calculate_offset: If set to TRUE, the timezone offset will be included in the returned field.

Return value

string An expression representing a timestamp with time zone.

Overrides QueryPluginBase::getDateField

File

core/modules/views/src/Plugin/views/query/Sql.php, line 1817

Class

Sql
Views query plugin for an SQL query.

Namespace

Drupal\views\Plugin\views\query

Code

public function getDateField($field, $string_date = FALSE, $calculate_offset = TRUE) {
  $field = $this->dateSql
    ->getDateField($field, $string_date);
  if ($calculate_offset && ($offset = $this
    ->getTimezoneOffset())) {
    $this
      ->setFieldTimezoneOffset($field, $offset);
  }
  return $field;
}