Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • Calendar
  • CalendarCollection
  • DateFormatter
  • DateTimeFormatter
  • FileCache
  • Locale
  • LocaleCollection
  • LocalizedDateTime
  • LocalizedObject
  • Provider
  • Repository
  • Retriever
  • RunTimeCache
  • Supplemental
  • TimeFormatter

Interfaces

  • Cache

Exceptions

  • ResourceNotFound

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.

Direct known subclasses

ICanBoogie\CLDR\DateFormatter, ICanBoogie\CLDR\TimeFormatter

Namespace: ICanBoogie\CLDR
Located at vendor/icanboogie/cldr/lib/formatters/datetime.php

Methods summary

protected static array
# tokenize( string $pattern )

Parses the datetime format pattern.

Parses the datetime format pattern.

Parameters

$pattern
string
$pattern the pattern to be parsed

Returns

array
tokenized parsing result
public
# __construct( ICanBoogie\CLDR\Calendar $calendar )

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

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

Parameters

$calendar
ICanBoogie\CLDR\Calendar
$calendar
public mixed
# __get( string $property )

Support of the ICanBoogie\CLDR\DateTimeFormatter::$calendar magic property.

Support of the ICanBoogie\CLDR\DateTimeFormatter::$calendar magic property.

Parameters

$property
string
$property

Returns

mixed

Throws

ICanBoogie\PropertyNotDefined
in attempt to get an undefined and unsupported property.
public string
# format( DateTime|string|integer $datetime, string $pattern_or_width_or_skeleton )

Formats a date according to a pattern.

Formats a date according to a pattern.

<?php

$datetime_formatter = $repository->locales['en']->calendar->datetime_formatter;
$datetime = '2013-11-02 22:23:45';

echo $datetime_formatter($datetime, "MMM d, y");                 // November 2, 2013 at 10:23:45 PM
echo $datetime_formatter($datetime, "MMM d, y 'at' hh:mm:ss a"); // November 2, 2013 at 10:23:45 PM
echo $datetime_formatter($datetime, 'full');                     // Saturday, November 2, 2013 at 10:23:45 PM CET
echo $datetime_formatter($datetime, 'long');                     // November 2, 2013 at 10:23:45 PM CET
echo $datetime_formatter($datetime, 'medium');                   // Nov 2, 2013, 10:23:45 PM
echo $datetime_formatter($datetime, 'short');                    // 11/2/13, 10:23 PM
echo $datetime_formatter($datetime, ':Ehm');                     // Sat 10:23 PM

Parameters

$datetime
DateTime|string|integer
$datetime The datetime to format.
$pattern_or_width_or_skeleton
string
$pattern_or_width_or_skeleton The datetime can be formatted using a pattern, a width or a skeleton. The following width are defined: "full", "long", "medium" and "short". 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
protected string
# resolve_pattern( string $pattern_or_width_or_skeleton )

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
string
$pattern_or_width_or_skeleton

Returns

string
public
# __invoke( mixed $datetime, mixed $pattern_or_width_or_skeleton )

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

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

protected string
# format_era( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Era - Replaced with the Era string for the current date. One to three letters for the abbreviated form, four letters for the long form, five for the narrow form. [1..3,4,5]

Era - Replaced with the Era string for the current date. One to three letters for the abbreviated form, four letters for the long form, five for the narrow form. [1..3,4,5]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
era
protected string
# format_year( ICanBoogie\CLDR\Datetime $datetime, string $pattern, integer $length )

Year. Normally the length specifies the padding, but for two letters it also specifies the maximum length. [1..n]

Year. Normally the length specifies the padding, but for two letters it also specifies the maximum length. [1..n]

Parameters

$datetime
Datetime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
formatted year
protected string
# format_quarter( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Quarter - Use one or two "Q" for the numerical quarter, three for the abbreviation, or four for the full (wide) name. [1..2,3,4]

Quarter - Use one or two "Q" for the numerical quarter, three for the abbreviation, or four for the full (wide) name. [1..2,3,4]

Parameters

$datetime
DateTime
$datetime Datetime.
$pattern
string
$pattern Pattern.
$length
integer
$length Number of repetition.

Returns

string
protected string
# format_standalone_quarter( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Stand-Alone Quarter - Use one or two "q" for the numerical quarter, three for the abbreviation, or four for the full (wide) name. [1..2,3,4]

Stand-Alone Quarter - Use one or two "q" for the numerical quarter, three for the abbreviation, or four for the full (wide) name. [1..2,3,4]

Parameters

$datetime
array
$date result of getdate().
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
protected string
# format_month( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Month - Use one or two "M" for the numerical month, three for the abbreviation, four for the full name, or five for the narrow name. [1..2,3,4,5]

Month - Use one or two "M" for the numerical month, three for the abbreviation, four for the full name, or five for the narrow name. [1..2,3,4,5]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
protected string
# format_standalone_month( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Stand-Alone Month - Use one or two "L" for the numerical month, three for the abbreviation, or four for the full (wide) name, or 5 for the narrow name. [1..2,3,4,5]

Stand-Alone Month - Use one or two "L" for the numerical month, three for the abbreviation, or four for the full (wide) name, or 5 for the narrow name. [1..2,3,4,5]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
formatted month.
protected integer
# format_week_of_year( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Week of Year. [1..2]

Week of Year. [1..2]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

integer
protected integer
# format_week_of_month( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Week of Month. [1]

Week of Month. [1]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

integer
week of month
protected string
# format_day_of_month( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Date - Day of the month. [1..2]

Date - Day of the month. [1..2]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
day of the month
protected string
# format_day_of_year( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Day of year. [1..3]

Day of year. [1..3]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
protected integer
# format_day_of_week_in_month( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Day of Week in Month. The example is for the 2nd Wed in July. [1]

Day of Week in Month. The example is for the 2nd Wed in July. [1]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

integer
protected string
# format_day_in_week( ICanBoogie\DateTime $datetime, string $pattern )

Day of week - Use one through three letters for the short day, or four for the full name, five for the narrow name, or six for the short name. [1..3,4,5,6]

Day of week - Use one through three letters for the short day, or four for the full name, five for the narrow name, or six for the short name. [1..3,4,5,6]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.

Returns

string
protected string
# format_period( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

AM or PM. [1]

AM or PM. [1]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
AM or PM designator
protected string
# format_hour12( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Hour [1-12]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern generation, it should match the 12-hour-cycle format preferred by the locale (h or K); it should not match a 24-hour-cycle format (H or k). Use hh for zero padding. [1..2]

Hour [1-12]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern generation, it should match the 12-hour-cycle format preferred by the locale (h or K); it should not match a 24-hour-cycle format (H or k). Use hh for zero padding. [1..2]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
protected string
# format_hour24( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Hour [0-23]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern generation, it should match the 24-hour-cycle format preferred by the locale (H or k); it should not match a 12-hour-cycle format (h or K). Use HH for zero padding. [1..2]

Hour [0-23]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern generation, it should match the 24-hour-cycle format preferred by the locale (H or k); it should not match a 12-hour-cycle format (h or K). Use HH for zero padding. [1..2]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
protected integer
# format_hour_in_period( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Hour [0-11]. When used in a skeleton, only matches K or h, see above. Use KK for zero padding. [1..2]

Hour [0-11]. When used in a skeleton, only matches K or h, see above. Use KK for zero padding. [1..2]

Parameters

$datetime
ICanBoogie\DateTime
$datetime.
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

integer
hours in AM/PM format.
protected integer
# format_hour_in_day( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Hour [1-24]. When used in a skeleton, only matches k or H, see above. Use kk for zero padding. [1..2]

Hour [1-24]. When used in a skeleton, only matches k or H, see above. Use kk for zero padding. [1..2]

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

integer
protected string
# format_minutes( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Minute. Use one or two "m" for zero padding.

Minute. Use one or two "m" for zero padding.

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition

Returns

string
minutes.
protected string
# format_seconds( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Second. Use one or two "s" for zero padding.

Second. Use one or two "s" for zero padding.

Parameters

$datetime
ICanBoogie\DateTime
$datetime
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
seconds
protected string
# format_timezone( ICanBoogie\DateTime $datetime, string $pattern, integer $length )

Time Zone.

Time Zone.

Parameters

$datetime
ICanBoogie\DateTime
$datetime.
$pattern
string
$pattern a pattern.
$length
integer
$length Number of repetition.

Returns

string
time zone

Magic methods summary

Properties summary

protected static array $formatters
#

Pattern characters mapping to the corresponding translator methods.

Pattern characters mapping to the corresponding translator methods.

protected ICanBoogie\CLDR\Calendar $calendar
#

The calendar used to format the datetime.

The calendar used to format the datetime.

Magic properties

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

The calendar used by the formatter.

The calendar used by the formatter.

Autodoc API documentation generated by ApiGen 2.8.0