Documentation

formatDate

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

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

The following format parts converted::

  • 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 is SQL unsafe.

Parameters

ParameterDescriptionVersion
$formatFormat.
$fieldDatabase field or expression.

Examples



© «Bitrix24», 2001-2024
Up