Skip to content

Commit

Permalink
Added info about new CakeTime methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Apr 22, 2012
1 parent 2179d24 commit afce427
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
22 changes: 13 additions & 9 deletions en/appendices/new-features-in-cakephp-2-2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ Models
Pagination
==========

Paginating custom finders will now return correct counts, see Model changes for more info.
- Paginating custom finders will now return correct counts, see Model changes for more info.

Utility
=======

CakeTime
--------

The ``$userOffset`` parameter has been replaced with ``$timezone`` parameter in all relevant functions.
So instead of numeric offset you can now pass in a timezone string or DateTimeZone object.
Passing numeric offsets for ``$timezone`` parameter is still possible for backwards compatibility.
- The ``$userOffset`` parameter has been replaced with ``$timezone`` parameter in all relevant functions.
So instead of numeric offset you can now pass in a timezone string or DateTimeZone object.
Passing numeric offsets for ``$timezone`` parameter is still possible for backwards compatibility.

- New methods added:
:php:meth:`CakeTime::toServer()`
:php:meth:`CakeTime::timezone()`

Configuration
=============

A new config parameter 'Config.timezone' is available which you can set to user's timezone string.
eg. You can do ``Configure::write('Config.timezone', 'Europe/Paris')``.
If a method of ``CakeTime`` class is called with ``$timezone`` parameter as null and 'Config.timezone' is set, then the
value of 'Config.timezone' will be used. This feature allows you to set user's timezone just once instead
of passing it each time in function calls.
- A new config parameter 'Config.timezone' is available which you can set to user's timezone string.
eg. You can do ``Configure::write('Config.timezone', 'Europe/Paris')``.
If a method of ``CakeTime`` class is called with ``$timezone`` parameter as null and 'Config.timezone' is set,
then thevalue of 'Config.timezone' will be used. This feature allows you to set user's timezone just once
instead of passing it each time in function calls.

17 changes: 17 additions & 0 deletions en/core-utility-libraries/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,23 @@ Formatting

A wrapper for fromString.

.. php:method:: toServer($dateString, $timezone = NULL, $format = 'Y-m-d H:i:s')
:rtype: mixed

.. versionadded:: 2.2

Returns a formatted date in server's timezone.

.. php:method:: timezone($timezone = NULL)
:rtype: DateTimeZone

.. versionadded:: 2.2

Returns a timezone object from a string or the user's timezone object. If the function is called
without a parameter it tries to get timezone from 'Config.timezone' configuration variable.

Testing Time
============

Expand Down

0 comments on commit afce427

Please sign in to comment.