From d38f1f27759d2ed3c41bf1167f4428973b877450 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 13 Feb 2024 10:14:39 +0900 Subject: [PATCH] docs: add user guide --- user_guide_src/source/changelogs/v4.5.0.rst | 6 ++++++ user_guide_src/source/database/configuration.rst | 3 ++- user_guide_src/source/models/model.rst | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.5.0.rst b/user_guide_src/source/changelogs/v4.5.0.rst index 591879b0ebfb..1cbb9d85b910 100644 --- a/user_guide_src/source/changelogs/v4.5.0.rst +++ b/user_guide_src/source/changelogs/v4.5.0.rst @@ -317,6 +317,12 @@ not changed. See :ref:`Using CodeIgniter’s Model ` for details. +Saving Dates +------------ + +Now you can configure the date/time format when you save :doc:`Time <../libraries/time>` +instances. See :ref:`model-saving-dates` for details. + Libraries ========= diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index b59242c2d56b..d9a33f7b9cff 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -191,7 +191,8 @@ Explanation of Values: * ``datetime-us`` - date and time with microsecond format * ``time`` - time format This can be used since v4.5.0, and you can get the value, e.g., ``$db->dateFormat['datetime']``. - Currently, the database drivers do not use these values directly, but just provide the values. + Currently, the database drivers do not use these values directly, + but :ref:`Model ` uses them. ================ =========================================================================================================== .. _DateTime format: https://www.php.net/manual/en/datetime.format.php diff --git a/user_guide_src/source/models/model.rst b/user_guide_src/source/models/model.rst index 9c5499029988..e80430619eb6 100644 --- a/user_guide_src/source/models/model.rst +++ b/user_guide_src/source/models/model.rst @@ -458,6 +458,21 @@ model's ``save()`` method to inspect the class, grab any public and private prop .. note:: If you find yourself working with Entities a lot, CodeIgniter provides a built-in :doc:`Entity class ` that provides several handy features that make developing Entities simpler. +.. _model-saving-dates: + +Saving Dates +------------ + +.. versionadded:: 4.5.0 + +When saving data, if you pass :doc:`Time <../libraries/time>` instances, they are +converted to strings with the format defined in ``dateFormat['datetime']`` and +``dateFormat['date']`` in the +:ref:`database configuration `. + +.. note:: Prior to v4.5.0, the date/time formats were hard coded as ``Y-m-d H:i:s`` + and ``Y-m-d`` in the Model class. + Deleting Data =============