ICanBoogie
  • Documentation
  • API Reference
  • CLDR master
Namespaces
  • ICanBoogie
    • CLDR
      • Plurals
      • Units
Classes
  • AbstractCollection
  • AbstractSectionCollection
  • Calendar
  • CalendarCollection
  • ContextTransforms
  • Currency
  • CurrencyCollection
  • CurrencyFormatter
  • DateFormatter
  • DateTimeAccessor
  • DateTimeFormatter
  • FileProvider
  • ListFormatter
  • Locale
  • LocaleCollection
  • LocalizedCurrency
  • LocalizedDateTime
  • LocalizedListFormatter
  • LocalizedLocale
  • LocalizedNumberFormatter
  • LocalizedObject
  • LocalizedObjectWithFormatter
  • LocalizedTerritory
  • Number
  • NumberFormatter
  • NumberPattern
  • NumberPatternParser
  • Numbers
  • Plurals
  • ProviderCollection
  • RedisProvider
  • Repository
  • RunTimeProvider
  • Supplemental
  • Territory
  • TerritoryCollection
  • TimeFormatter
  • Units
  • WebProvider
Interfaces
  • Exception
  • Formatter
  • LocalizeAwareInterface
  • Provider
Traits
  • CodePropertyTrait
  • CollectionTrait
  • LocalePropertyTrait
  • LocalizeTrait
  • ProviderStorageBinding
  • RepositoryPropertyTrait
Exceptions
  • ResourceNotFound
  • TerritoryNotDefined

Class DateTimeFormatter

Provides date and time localization.

The class allows you to format dates and times in a locale-sensitive manner using Unicode format patterns.

ICanBoogie\CLDR\DateTimeFormatter implements ICanBoogie\CLDR\Formatter uses ICanBoogie\Accessor\AccessorTrait (not available)

Direct known subclasses

ICanBoogie\CLDR\DateFormatter, ICanBoogie\CLDR\TimeFormatter

Namespace: ICanBoogie\CLDR
Located at DateTimeFormatter.php

Methods summary

protected static tokenize( string $pattern ) : array

Parses the datetime format pattern.

Parses the datetime format pattern.

Parameters

$pattern
The pattern to be parsed.

Returns

array
Tokenized parsing result.
protected get_calendar( void ) : ICanBoogie\CLDR\Calendar

Returns

ICanBoogie\CLDR\Calendar
public __construct( ICanBoogie\CLDR\Calendar $calendar )

Initializes the ICanBoogie\CLDR\DateTimeFormatter::$calendar property.

Initializes the ICanBoogie\CLDR\DateTimeFormatter::$calendar property.

Parameters

$calendar
public __invoke( mixed $datetime, string $pattern_or_width_or_skeleton ) : string

Alias to the ICanBoogie\CLDR\DateTimeFormatter::format() method.

Alias to the ICanBoogie\CLDR\DateTimeFormatter::format() method.

Parameters

$datetime
$pattern_or_width_or_skeleton

Returns

string
public format( DateTimeInterface|string|integer $datetime, string $pattern_or_width_or_skeleton ) : string

Formats a date according to a pattern.

Formats a date according to a pattern.

Parameters

$datetime
The datetime to format.
$pattern_or_width_or_skeleton

The datetime can be formatted using a pattern, a width (WIDTH_*) or a skeleton. To format the datetime using a so-called "skeleton", the skeleton identifier must be prefixed with the colon sign ":" e.g. ":Ehm". The skeleton identifies the patterns defined under availableFormats.

Returns

string
The formatted date time.

See

http://www.unicode.org/reports/tr35/#Date_Format_Patterns

Uses

format_era
format_year
format_standalone_quarter
format_standalone_month
format_week_of_year
format_week_of_month
format_day_of_month
format_day_of_year
format_day_of_week_in_month
format_day_in_week
format_day_in_week_stand_alone
format_day_in_week_local
format_period
format_hour12
format_hour24
format_hour_in_period
format_hour_in_day
format_minutes
format_seconds
format_timezone_basic
format_timezone_non_location
protected resolve_pattern( string $pattern_or_width_or_skeleton ) : string

Resolves the specified pattern, which can be a width, a skeleton or an actual pattern.

Resolves the specified pattern, which can be a width, a skeleton or an actual pattern.

Parameters

$pattern_or_width_or_skeleton

Returns

string
protected resolve_width( string $pattern_or_width_or_skeleton, string $from ) : string

Resolves widths (full, long, medium, short) into a pattern.

Resolves widths (full, long, medium, short) into a pattern.

Parameters

$pattern_or_width_or_skeleton
$from
Width Source e.g. "timeFormats".

Returns

string

Constants summary

WIDTH_FULL : string
'full'
WIDTH_LONG : string
'long'
WIDTH_MEDIUM : string
'medium'
WIDTH_SHORT : string
'short'

Properties summary

protected static $formatters : array

Pattern characters mapping to the corresponding translator methods.

Pattern characters mapping to the corresponding translator methods.

[

    'G' => 'format_era',
    'y' => 'format_year',
//      'Y' => Year (in "Week of Year" based calendars).
//      'u' => Extended year.
    'Q' => 'format_quarter',
    'q' => 'format_standalone_quarter',
    'M' => 'format_month',
    'L' => 'format_standalone_month',
//      'l' => Special symbol for Chinese leap month, used in combination with M. Only used with the Chinese calendar.
    'w' => 'format_week_of_year',
    'W' => 'format_week_of_month',
    'd' => 'format_day_of_month',
    'D' => 'format_day_of_year',
    'F' => 'format_day_of_week_in_month',

    'h' => 'format_hour12',
    'H' => 'format_hour24',
    'm' => 'format_minutes',
    's' => 'format_seconds',
    'E' => 'format_day_in_week',
    'c' => 'format_day_in_week_stand_alone',
    'e' => 'format_day_in_week_local',
    'a' => 'format_period',
    'k' => 'format_hour_in_day',
    'K' => 'format_hour_in_period',
    'z' => 'format_timezone_non_location',
    'Z' => 'format_timezone_basic',
    'v' => 'format_timezone_non_location'

]
protected $calendar : ICanBoogie\CLDR\Calendar

The calendar used to format the datetime.

The calendar used to format the datetime.


		

Magic properties

public read-only $calendar : ICanBoogie\CLDR\Calendar

The calendar used by the formatter.

CLDR master – Check on GitHub – API documentation generated by ApiGen