Class TimeHelper
Time Helper class for easy use of time data.
Manipulation of time data.
- AppHelper
- TimeHelper
Link: http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html
See:
CakeTime
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/View/Helper/TimeHelper.php
Properties summary
-
$_engine
protectedCakeTime instance
Method Summary
-
__call() public
Call methods from CakeTime utility class -
__construct() public
Constructor -
__get() public
Magic accessor for attributes that were deprecated. -
__isset() public
Magic isset check for deprecated attributes. -
__set() public
Magic accessor for deprecated attributes. -
convert() public
-
convertSpecifiers() public
-
dayAsSql() public
-
daysAsSql() public
-
format() public
-
fromString() public
-
gmt() public
-
i18nFormat() public
-
isThisMonth() public
-
isThisWeek() public
-
isThisYear() public
-
isToday() public
-
isTomorrow() public
-
nice() public
-
niceShort() public
-
serverOffset() public
-
timeAgoInWords() public
-
toAtom() public
-
toQuarter() public
-
toRSS() public
-
toUnix() public
-
wasWithinLast() public
-
wasYesterday() public
Method Detail
__construct() public ¶
__construct( View
$View , array $settings = array() )
Constructor
Settings:
engine
Class name to use to replace CakeTime functionality The class needs to be placed in theUtility
directory.
Parameters
-
View
$View - the view object the helper is attached to.
- array $settings optional array()
- Settings array Settings array
Throws
__get() public ¶
__get( string $name )
Magic accessor for attributes that were deprecated.
Parameters
- string $name
- Name of the attribute to get.
Returns
__isset() public ¶
__isset( string $name )
Magic isset check for deprecated attributes.
Parameters
- string $name
- Name of the attribute to check.
Returns
__set() public ¶
__set( string $name , string $value )
Magic accessor for deprecated attributes.
Parameters
- string $name
- Name of the attribute to set.
- string $value
- Value of the attribute to set.
Returns
convert() public ¶
convert( string $serverTime , integer $userOffset )
Parameters
- string $serverTime
- UNIX timestamp
- integer $userOffset
- User's offset from GMT (in hours)
Returns
UNIX timestamp
See
Link
convertSpecifiers() public ¶
convertSpecifiers( string $format , string $time = null )
Parameters
- string $format
Format with specifiers for strftime function. Accepts the special specifier %S which mimics the modifier S for date()
- string $time optional null
- UNIX timestamp
Returns
windows safe and date() function compatible format for strftime
See
Link
dayAsSql() public ¶
dayAsSql( string $dateString , string $fieldName , integer $userOffset = null )
Parameters
- string $dateString
- Datetime string or Unix timestamp
- string $fieldName
- Name of database field to compare with
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
Partial SQL string.
See
Link
daysAsSql() public ¶
daysAsSql( string $begin , string $end , string $fieldName , integer $userOffset = null )
Parameters
- string $begin
- Datetime string or Unix timestamp
- string $end
- Datetime string or Unix timestamp
- string $fieldName
- Name of database field to compare with
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
Partial SQL string.
See
Link
format() public ¶
format( string $format , string $date = null , boolean $invalid = false , integer $userOffset = null )
Parameters
- string $format
- date format string (or a DateTime string)
- string $date optional null
- Datetime string (or a date format string)
- boolean $invalid optional false
- flag to ignore results of fromString == false
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
Formatted date string
See
Link
fromString() public ¶
fromString( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- Datetime string
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
Parsed timestamp
See
Link
gmt() public ¶
gmt( string $string = null )
Parameters
- string $string optional null
- UNIX timestamp or a valid strtotime() date string
Returns
UNIX timestamp
See
Link
i18nFormat() public ¶
i18nFormat( string $date , string $format = null , boolean $invalid = false , integer $userOffset = null )
Parameters
- string $date
- Datetime string
- string $format optional null
- strftime format string.
- boolean $invalid optional false
- flag to ignore results of fromString == false
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
Formatted and translated date string
See
Link
isThisMonth() public ¶
isThisMonth( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
True if datetime string is within current month
See
Link
isThisWeek() public ¶
isThisWeek( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
True if datetime string is within current week
See
Link
isThisYear() public ¶
isThisYear( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- Datetime string or Unix timestamp
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
True if datetime string is within current year
See
Link
isToday() public ¶
isToday( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- Datetime string or Unix timestamp
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
True if datetime string is today
See
Link
isTomorrow() public ¶
isTomorrow( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- Datetime string or Unix timestamp
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
True if datetime string was yesterday
See
Link
nice() public ¶
nice( string $dateString = null , integer $userOffset = null , string $format = null )
Parameters
- string $dateString optional null
- Datetime string or Unix timestamp
- integer $userOffset optional null
- User's offset from GMT (in hours)
- string $format optional null
- The format to use. If null,
TimeHelper::$niceFormat
is used
Returns
Formatted date string
See
Link
niceShort() public ¶
niceShort( string $dateString = null , integer $userOffset = null )
Parameters
- string $dateString optional null
- Datetime string or Unix timestamp
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
Described, relative date string
See
Link
timeAgoInWords() public ¶
timeAgoInWords( string $dateTime , array $options = array() )
Parameters
- string $dateTime
- Datetime string or Unix timestamp
- array $options optional array()
- Default format if timestamp is used in $dateString
Returns
Relative time string.
See
Link
toAtom() public ¶
toAtom( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- Datetime string or Unix timestamp
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
Formatted date string
See
Link
toQuarter() public ¶
toQuarter( string $dateString , boolean $range = false )
Parameters
- string $dateString
- boolean $range optional false
- if true returns a range in Y-m-d format
Returns
1, 2, 3, or 4 quarter of year or array if $range true
See
Link
toRSS() public ¶
toRSS( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- Datetime string or Unix timestamp
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
Formatted date string
See
Link
toUnix() public ¶
toUnix( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- Datetime string to be represented as a Unix timestamp
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
Unix timestamp
See
Link
wasWithinLast() public ¶
wasWithinLast( mixed $timeInterval , mixed $dateString , integer $userOffset = null )
Parameters
- mixed $timeInterval
the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute.
- mixed $dateString
- the datestring or unix timestamp to compare
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
See
Link
wasYesterday() public ¶
wasYesterday( string $dateString , integer $userOffset = null )
Parameters
- string $dateString
- Datetime string or Unix timestamp
- integer $userOffset optional null
- User's offset from GMT (in hours)
Returns
True if datetime string was yesterday