Functions | |
| format_rss_channel ($title, $link, $description, $items, $langcode=NULL, $args=array()) | |
| format_rss_item ($title, $link, $description, $args=array()) | |
| format_xml_elements ($array) | |
| format_plural ($count, $singular, $plural, $args=array(), $langcode=NULL) | |
| parse_size ($size) | |
| format_size ($size, $langcode=NULL) | |
| format_interval ($timestamp, $granularity=2, $langcode=NULL) | |
| format_date ($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL) | |
| format_date | ( | $ | timestamp, | |
| $ | type = 'medium', |
|||
| $ | format = '', |
|||
| $ | timezone = NULL, |
|||
| $ | langcode = NULL | |||
| ) |
Format a date with the given configured format or a custom format string.
Drupal allows administrators to select formatting strings for 'small', 'medium' and 'large' date formats. This function can handle these formats, as well as any custom format.
| $timestamp | The exact date to format, as a UNIX timestamp. | |
| $type | The format to use. Can be "small", "medium" or "large" for the preconfigured date formats. If "custom" is specified, then $format is required as well. | |
| $format | A PHP date format string as required by date(). A backslash should be used before a character to avoid interpreting the character as part of a date format. | |
| $timezone | Time zone offset in seconds; if omitted, the user's time zone is used. | |
| $langcode | Optional language code to translate to a language other than what is used to display the page. |
| format_interval | ( | $ | timestamp, | |
| $ | granularity = 2, |
|||
| $ | langcode = NULL | |||
| ) |
Format a time interval with the requested granularity.
| $timestamp | The length of the interval in seconds. | |
| $granularity | How many different units to display in the string. | |
| $langcode | Optional language code to translate to a language other than what is used to display the page. |
| format_plural | ( | $ | count, | |
| $ | singular, | |||
| $ | plural, | |||
| $ | args = array(), |
|||
| $ | langcode = NULL | |||
| ) |
Format a string containing a count of items.
This function ensures that the string is pluralized correctly. Since t() is called by this function, make sure not to pass already-localized strings to it.
For example:
$output = format_plural($node->comment_count, '1 comment', '@count comments');
Example with additional replacements:
$output = format_plural($update_count, 'Changed the content type of 1 post from %old-type to %new-type.', 'Changed the content type of @count posts from %old-type to %new-type.', array('%old-type' => $info->old_type, '%new-type' => $info->new_type)));
| $count | The item count to display. | |
| $singular | The string for the singular case. Please make sure it is clear this is singular, to ease translation (e.g. use "1 new comment" instead of "1 new"). Do not use in the singular string. | |
| $plural | The string for the plural case. Please make sure it is clear this is plural, to ease translation. Use in place of the item count, as in " new comments". | |
| $args | An associative array of replacements to make after translation. Incidences of any key in this array are replaced with the corresponding value. Based on the first character of the key, the value is escaped and/or themed:
| |
| $langcode | Optional language code to translate to a language other than what is used to display the page. |
| format_rss_channel | ( | $ | title, | |
| $ | link, | |||
| $ | description, | |||
| $ | items, | |||
| $ | langcode = NULL, |
|||
| $ | args = array() | |||
| ) |
Formats an RSS channel.
Arbitrary elements may be added using the $args associative array.
| format_rss_item | ( | $ | title, | |
| $ | link, | |||
| $ | description, | |||
| $ | args = array() | |||
| ) |
Format a single RSS item.
Arbitrary elements may be added using the $args associative array.
| format_size | ( | $ | size, | |
| $ | langcode = NULL | |||
| ) |
Generate a string representation for the given byte count.
| $size | A size in bytes. | |
| $langcode | Optional language code to translate to a language other than what is used to display the page. |
| format_xml_elements | ( | $ | array | ) |
Format XML elements.
| $array | An array where each item represent an element and is either a:
|
| parse_size | ( | $ | size | ) |
Parse a given byte count.
| $size | A size expressed as a number of bytes with optional SI size and unit suffix (e.g. 2, 3K, 5MB, 10G). |