You are here

public function MysqlDateSql::getDateFormat in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/query/MysqlDateSql.php \Drupal\views\Plugin\views\query\MysqlDateSql::getDateFormat()
  2. 9 core/modules/views/src/Plugin/views/query/MysqlDateSql.php \Drupal\views\Plugin\views\query\MysqlDateSql::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/MysqlDateSql.php, line 72

Class

MysqlDateSql
MySQL-specific date handling.

Namespace

Drupal\views\Plugin\views\query

Code

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