Documentation

formatDate

string public
\Bitrix\Main\DB\MysqlCommonSqlHelper::formatDate(
 string $format,
 string $field = null
);

This non-static method returns database expression for converting $field value according the $format.

The following format parts are converted:

YYYY
  • YYYY - A full numeric representation of a year, 4 digits.
  • MMMM - A full textual representation of a month, such as January or March.
  • MM - Numeric representation of a month, with leading zeros.
  • MI - Minutes with leading zeros.
  • M - A short textual representation of a month, three letters.
  • DD - Day of the month, 2 digits with leading zeros.
  • HH - 24-hour format of an hour with leading zeros.
  • H - 24-hour format of an hour without leading zeros.
  • GG - 12-hour format of an hour with leading zeros.
  • G - 12-hour format of an hour without leading zeros.
  • SS - Seconds with leading zeros.
  • TT - AM or PM
  • T - AM or PM.

$field parameter is SQL unsafe.

Parameters

ParameterDescriptionVersion
$formatFormat.
$fieldDatabase area or expression.

Examples



© «Bitrix24», 2001-2024
Up