You are here

public function PostgresqlDateSql::getDateFormat in Drupal 8

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

Creates a native database date formatting.

Parameters

string $field: An appropriate query expression pointing to the date field.

string $format: A format string for the result. For example: 'Y-m-d H:i:s'.

Return value

string A string representing the field formatted as a date as specified by $format.

Overrides DateSqlInterface::getDateFormat

File

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

Class

PostgresqlDateSql
PostgreSQL-specific date handling.

Namespace

Drupal\views\Plugin\views\query

Code

public function getDateFormat($field, $format) {
  $format = strtr($format, static::$replace);
  return "TO_CHAR({$field}, '{$format}')";
}