Skip to content

Commit 64b6684

Browse files
committed
docs: add user guide
1 parent c8b9397 commit 64b6684

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

user_guide_src/source/changelogs/v4.3.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Others
7070
- Added new Form helper function :php:func:`validation_errors()`, :php:func:`validation_list_errors()` and :php:func:`validation_show_error()` to display Validation Errors.
7171
- Now you can autoload helpers by **app/Config/Autoload.php**.
7272
- ``BaseConnection::escape()`` now excludes the ``RawSql`` data type. This allows passing SQL strings into data.
73+
- Added :ref:`Time::toDatabase() <time-todatabase>` to get a datetime string that can be used with databases regardless of locale.
7374

7475
Changes
7576
*******

user_guide_src/source/libraries/time.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ Displays just the localized version of time portion of the value:
171171

172172
.. literalinclude:: time/018.php
173173

174+
.. _time-todatabase:
175+
176+
toDatabase()
177+
============
178+
179+
.. versionadded:: 4.3.0
180+
181+
This method returns a string that can be used with databases regardless of locale.
182+
183+
.. literalinclude:: time/042.php
184+
174185
humanize()
175186
==========
176187

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
// Locale: en
4+
$time = Time::parse('March 9, 2016 12:00:00', 'America/Chicago');
5+
echo $time->toDatabase(); // '2016-03-09 12:00:00'
6+
7+
// Locale: fa
8+
$time = Time::parse('March 9, 2016 12:00:00', 'America/Chicago');
9+
echo $time->toDatabase(); // '2016-03-09 12:00:00'

0 commit comments

Comments
 (0)