CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.1 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.1
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • CacheHelper
  • FormHelper
  • HtmlHelper
  • JqueryEngineHelper
  • JsBaseEngineHelper
  • JsHelper
  • MootoolsEngineHelper
  • NumberHelper
  • PaginatorHelper
  • PrototypeEngineHelper
  • RssHelper
  • SessionHelper
  • TextHelper
  • TimeHelper

Class TimeHelper

Time Helper class for easy use of time data.

Manipulation of time data.

AppHelper
Extended by TimeHelper
Package: Cake\View\Helper
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 protected
    CakeTime 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

__call() public ¶

__call( $method , $params )

Call methods from CakeTime utility class

__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 the Utility directory.
Parameters
View $View
the view object the helper is attached to.
array $settings optional array()
Settings array Settings array
Throws
CakeException
When the engine class could not be found.

__get() public ¶

__get( string $name )

Magic accessor for attributes that were deprecated.

Parameters
string $name
Name of the attribute to get.
Returns
mixed

__isset() public ¶

__isset( string $name )

Magic isset check for deprecated attributes.

Parameters
string $name
Name of the attribute to check.
Returns
boolean

__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
mixed

convert() public ¶

convert( string $serverTime , integer $userOffset )

Parameters
string $serverTime
UNIX timestamp
integer $userOffset
User's offset from GMT (in hours)
Returns
integer
UNIX timestamp
See
CakeTime::convert()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
windows safe and date() function compatible format for strftime
See
CakeTime::convertSpecifiers()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
Partial SQL string.
See
CakeTime::dayAsSql()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
Partial SQL string.
See
CakeTime::daysAsSql()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
Formatted date string
See
CakeTime::format()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
Parsed timestamp
See
CakeTime::fromString()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

gmt() public ¶

gmt( string $string = null )

Parameters
string $string optional null
UNIX timestamp or a valid strtotime() date string
Returns
integer
UNIX timestamp
See
CakeTime::gmt()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
Formatted and translated date string
See
CakeTime::i18nFormat()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

isThisMonth() public ¶

isThisMonth( string $dateString , integer $userOffset = null )

Parameters
string $dateString
integer $userOffset optional null
User's offset from GMT (in hours)
Returns
boolean
True if datetime string is within current month
See
CakeTime::isThisMonth()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time

isThisWeek() public ¶

isThisWeek( string $dateString , integer $userOffset = null )

Parameters
string $dateString
integer $userOffset optional null
User's offset from GMT (in hours)
Returns
boolean
True if datetime string is within current week
See
CakeTime::isThisWeek()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time

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
boolean
True if datetime string is within current year
See
CakeTime::isThisYear()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time

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
boolean
True if datetime string is today
See
CakeTime::isToday()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time

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
boolean
True if datetime string was yesterday
See
CakeTime::isTomorrow()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time

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
string
Formatted date string
See
CakeTime::nice()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
Described, relative date string
See
CakeTime::niceShort()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

serverOffset() public ¶

serverOffset( )

Returns
integer
Offset
See
CakeTime::serverOffset()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
Relative time string.
See
CakeTime::timeAgoInWords()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
Formatted date string
See
CakeTime::toAtom()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
mixed
1, 2, 3, or 4 quarter of year or array if $range true
See
CakeTime::toQuarter()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
string
Formatted date string
See
CakeTime::toRSS()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
integer
Unix timestamp
See
CakeTime::toUnix()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting

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
boolean
See
CakeTime::wasWithinLast()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time

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
boolean
True if datetime string was yesterday
See
CakeTime::wasYesterday()
Link
http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time

Properties detail

$_engine ¶

protected

CakeTime instance

null
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs