You are here

public function PostgresqlDateSql::getDateField in Drupal 10

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

Returns a native database expression for a given field.

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.

Return value

string An expression representing a date field with timezone.

Overrides DateSqlInterface::getDateField

File

core/modules/views/src/Plugin/views/query/PostgresqlDateSql.php, line 66

Class

PostgresqlDateSql
PostgreSQL-specific date handling.

Namespace

Drupal\views\Plugin\views\query

Code

public function getDateField($field, $string_date) {
  if ($string_date) {

    // Ensures compatibility with field offset operation below.
    return "TO_TIMESTAMP({$field}, 'YYYY-MM-DD\"T\"HH24:MI:SS')";
  }
  return "TO_TIMESTAMP({$field})";
}