symfony API

sfDateFormat Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.4 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.4 version. Switch to:

sfDateFormat class.

Method Summary

  • string format($time, $pattern, $inputPattern, $charset)
    Formats a date according to the pattern.
  • string getAMPM($date, $pattern)
    Get the AM/PM designator, 12 noon is PM, 12 midnight is AM.
  • array getDate($time, $pattern)
    Guesses a date without calling strtotime.
  • int getDayInMonth($date, $pattern)
    Gets day in the month.
  • string getEra($date, $pattern)
    Gets the era. i.e. in gregorian, year > 0 is AD, else BC.
  • mixed getFunctionName($token)
    For a particular token, get the corresponding function to call.
  • string getHour12($date, $pattern)
    Gets the hours in 12 hour format.
  • int getHourInAMPM($date, $pattern)
    Gets the hours in AM/PM format, e.g [1-12]
  • int getHourInDay($date, $pattern)
    Gets the hours [1-24].
  • string getHours($date, $pattern)
    Gets the hours in 24 hour format, i.e. [0-23].
  • string getInputPattern($pattern)
    Returns an easy to parse input pattern
  • string getMday($date, $pattern)
    Gets the day of the month.
  • string getMinutes($date, $pattern)
    Gets the minutes.
  • string getMon($date, $pattern)
    Gets the month.
  • string getPattern($pattern)
    Gets the pattern from DateTimeFormatInfo or some predefined patterns.
  • string getSeconds($date, $pattern)
    Gets the seconds.
  • string getTimeZone($date, $pattern)
    Gets the timezone from the server machine.
  • array getTokens($pattern)
    Tokenizes the pattern. The tokens are delimited by group of
  • getUnixDate()
  • string getWday($date, $pattern)
    Gets the day of the week.
  • int getWeekInMonth($date, $pattern)
    Gets week in the month.
  • int getWeekInYear($date, $pattern)
    Gets the week in the year.
  • int getYday($date, $pattern)
    Gets the day in the year, e.g. [1-366]
  • string getYear($date, $pattern)
    Gets the year.
  • sfDateFormat __construct($formatInfo)
    Initializes a new sfDateFormat.

Method Details

  • (string) format ($time, $pattern, $inputPattern, $charset) Browse code

    $time the time as integer or string in strtotime format.
    $pattern the pattern
    $inputPattern the input pattern
    $charset the charset

    Formats a date according to the pattern.

    returns formatted date time.

  • (string) getAMPM ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Get the AM/PM designator, 12 noon is PM, 12 midnight is AM.

    returns AM or PM designator

  • (array) getDate ($time, $pattern) Browse code

    $time the time as integer or string in strtotime format.
    $pattern the input pattern; default is sql date or timestamp

    Guesses a date without calling strtotime.

    returns same array as the getdate function

  • (int) getDayInMonth ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets day in the month.

    returns day in month

  • (string) getEra ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the era. i.e. in gregorian, year > 0 is AD, else BC.

    returns era

  • (mixed) getFunctionName ($token) Browse code

    $token token

    For a particular token, get the corresponding function to call.

    returns the function if good token, null otherwise.

  • (string) getHour12 ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the hours in 12 hour format.

    "h" for non-padding, "hh" will always return 2 characters.

    returns hours in 12 hour format.

  • (int) getHourInAMPM ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the hours in AM/PM format, e.g [1-12]

    returns hours in AM/PM format.

  • (int) getHourInDay ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the hours [1-24].

    returns hours [1-24]

  • (string) getHours ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the hours in 24 hour format, i.e. [0-23].

    "H" for non-padding, "HH" will always return 2 characters.

    returns hours in 24 hour format.

  • (string) getInputPattern ($pattern) Browse code

    $pattern pattern.

    Returns an easy to parse input pattern

    yy is replaced by yyyy and h by H

    returns input pattern

  • (string) getMday ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the day of the month.

    "d" for non-padding, "dd" will always return 2 characters.

    returns day of the month

  • (string) getMinutes ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the minutes.

    "m" for non-padding, "mm" will always return 2 characters.

    returns minutes.

  • (string) getMon ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the month.

    "M" will return integer 1 through 12
    "MM" will return integer 1 through 12 padded with 0 to two characters width
    "MMM" will return the abrreviated month name, e.g. "Jan"
    "MMMM" will return the month name, e.g. "January"
    "MMMMM" will return the narrow month name, e.g. "J"

    returns month name

  • (string) getPattern ($pattern) Browse code

    $pattern a pattern.

    Gets the pattern from DateTimeFormatInfo or some predefined patterns.

    If the $pattern parameter is an array of 2 element, it will assume
    that the first element is the date, and second the time
    and try to find an appropriate pattern and apply
    DateTimeFormatInfo::formatDateTime
    See the tutorial documentation for futher details on the patterns.

    returns a pattern.

  • (string) getSeconds ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the seconds.

    "s" for non-padding, "ss" will always return 2 characters.

    returns seconds

  • (string) getTimeZone ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the timezone from the server machine.

    returns time zone

  • (array) getTokens ($pattern) Browse code

    $pattern pattern.

    Tokenizes the pattern. The tokens are delimited by group of

    similar characters, e.g. 'aabb' will form 2 tokens of 'aa' and 'bb'.
    Any substrings, starting and ending with a single quote (')
    will be treated as a single token.

    returns string tokens in an array.

  • getUnixDate () Browse code

  • (string) getWday ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the day of the week.

    "E" will return integer 0 (for Sunday) through 6 (for Saturday).
    "EE" will return the narrow day of the week, e.g. "M"
    "EEE" will return the abrreviated day of the week, e.g. "Mon"
    "EEEE" will return the day of the week, e.g. "Monday"

    returns day of the week.

  • (int) getWeekInMonth ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern

    Gets week in the month.

    returns week in month

  • (int) getWeekInYear ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the week in the year.

    returns week in year

  • (int) getYday ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the day in the year, e.g. [1-366]

    returns hours in AM/PM format.

  • (string) getYear ($date, $pattern) Browse code

    $date getdate format.
    $pattern a pattern.

    Gets the year.

    "yy" will return the last two digits of year.
    "y", "yyy" and "yyyy" will return the full integer year.

    returns year

  • (sfDateFormat) __construct ($formatInfo) Browse code

    $formatInfo either, null, a sfCultureInfo instance, a DateTimeFormatInfo instance, or a locale.

    Initializes a new sfDateFormat.

    returns instance