[ Index ] |
|
Code source de CakePHP 1.1.13.4450 |
[Code source] [Imprimer] [Statistiques]
Time Helper class file. PHP versions 4 and 5
Copyright: | Copyright 2005-2007, Cake Software Foundation, Inc. |
License: | http://www.opensource.org/licenses/mit-license.php The MIT License |
Version: | $Revision: 4409 $ |
Poids: | 397 lignes (14 kb) |
Inclus ou requis: | 0 fois |
Référencé: | 0 fois |
Nécessite: | 0 fichiers |
TimeHelper:: (16 méthodes):
trim()
fromString()
nice()
niceShort()
isToday()
daysAsSql()
dayAsSql()
isThisYear()
wasYesterday()
isTomorrow()
toUnix()
toAtom()
toRSS()
timeAgoInWords()
relativeTime()
wasWithinLast()
Classe: TimeHelper - X-Ref
Time Helper class for easy use of time data.trim($string, $length, $ending = '..') X-Ref |
Returns given string trimmed to given length, adding an ending (default: "..") if necessary. param: string $string String to trim param: integer $length Length of returned string, excluding ellipsis param: string $ending Ending to be appended after trimmed string return: string Trimmed string |
fromString($date_string) X-Ref |
Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string. param: string $date_string Datetime string return: string Formatted date string |
nice($date_string = null, $return = false) X-Ref |
Returns a nicely formatted date string for given Datetime string. param: string $date_string Datetime string or Unix timestamp param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: string Formatted date string |
niceShort($date_string = null, $return = false) X-Ref |
Returns a formatted descriptive date string for given datetime string. If the given date is today, the returned string could be "Today, 16:54". If the given date was yesterday, the returned string could be "Yesterday, 16:54". If $date_string's year is the current year, the returned string does not include mention of the year. param: string $date_string Datetime string or Unix timestamp param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: string Described, relative date string |
isToday($date_string, $return = false) X-Ref |
Returns true if given datetime string is today. param: string $date_string Datetime string or Unix timestamp param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: boolean True if datetime string is today |
daysAsSql($begin, $end, $field_name, $return = false) X-Ref |
Returns a partial SQL string to search for all records between two dates. param: string $date_string Datetime string or Unix timestamp param: string $end Datetime string or Unix timestamp param: string $field_name Name of database field to compare with param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: string Partial SQL string. |
dayAsSql($date_string, $field_name, $return = false) X-Ref |
Returns a partial SQL string to search for all records between two times occurring on the same day. param: string $date_string Datetime string or Unix timestamp param: string $field_name Name of database field to compare with param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: string Partial SQL string. |
isThisYear($date_string, $return = false) X-Ref |
Returns true if given datetime string is within current year. param: string $date_string Datetime string or Unix timestamp param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: boolean True if datetime string is within current year |
wasYesterday($date_string, $return = false) X-Ref |
Returns true if given datetime string was yesterday. param: string $date_string Datetime string or Unix timestamp param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: boolean True if datetime string was yesterday |
isTomorrow($date_string, $return = false) X-Ref |
Returns true if given datetime string is tomorrow. param: string $date_string Datetime string or Unix timestamp param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: boolean True if datetime string was yesterday |
toUnix($date_string, $return = false) X-Ref |
Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime(). param: string $date_string Datetime string to be represented as a Unix timestamp param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: int Unix timestamp |
toAtom($date_string, $return = false) X-Ref |
Returns a date formatted for Atom RSS feeds. param: string $date_string Datetime string or Unix timestamp param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: string Formatted date string |
toRSS($date_string, $return = false) X-Ref |
Formats date for RSS feeds param: string $date_string Datetime string or Unix timestamp param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: string Formatted date string |
timeAgoInWords($datetime_string, $format = 'j/n/y', $backwards = false, $return = false) X-Ref |
Returns either a relative date or a formatted date depending on the difference between the current time and given datetime. $datetime should be in a <i>strtotime</i>-parsable format, like MySQL's datetime datatype. Relative dates look something like this: 3 weeks, 4 days ago 15 seconds ago Formatted dates look like this: on 02/18/2004 The returned string includes 'ago' or 'on' and assumes you'll properly add a word like 'Posted ' before the function output. param: string $date_string Datetime string or Unix timestamp param: string $format Default format if timestamp is used in $date_string param: string $backwards False if $date_string is in the past, true if in the future param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: string Relative time string. |
relativeTime($datetime_string, $format = 'j/n/y', $return = false) X-Ref |
Alias for timeAgoInWords param: string $date_string Datetime string or Unix timestamp param: string $format Default format if timestamp is used in $date_string param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: string Relative time string. |
wasWithinLast($timeInterval, $date_string, $return = false) X-Ref |
Returns true if specified datetime was within the interval specified, else false. param: mixed $timeInterval the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute. param: mixed $date_string the datestring or unix timestamp to compare param: boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. return: boolean |
Généré le : Sun Feb 25 19:27:47 2007 | par Balluche grâce à PHPXref 0.7 |