diff --git a/user_guide_src/source/libraries/time.rst b/user_guide_src/source/libraries/time.rst index d94a8cd58e..b18e563504 100644 --- a/user_guide_src/source/libraries/time.rst +++ b/user_guide_src/source/libraries/time.rst @@ -2,7 +2,7 @@ Times and Dates ############### -CodeIgniter provides a fully-localized, immutable, date/time class that is built on PHP's DateTimeImmutable object, but uses the Intl +CodeIgniter provides a fully-localized, immutable, date/time class that is built on PHP's DateTimeImmutable class, but uses the Intl extension's features to convert times across timezones and display the output correctly for different locales. This class is the ``Time`` class and lives in the ``CodeIgniter\I18n`` namespace. @@ -34,9 +34,9 @@ This can be any string that PHP's `DateTimeImmutable`_ constructor can parse. Se .. literalinclude:: time/001.php -You can pass in strings representing the timezone and the locale in the second and parameters, respectively. Timezones -can be any supported by PHP's `DateTimeZone `__ class. The locale can be -any supported by PHP's `Locale `__ class. If no locale or timezone is +You can pass in strings representing the timezone and the locale in the second and the third parameters, respectively. The timezone +can be any one supported by PHP's `DateTimeZone `__ class. The locale can be +any one supported by PHP's `Locale `__ class. If no locale or timezone is provided, the application defaults will be used. .. literalinclude:: time/002.php @@ -45,8 +45,8 @@ now() ===== The Time class has several helper methods to instantiate the class. The first of these is the ``now()`` method -that returns a new instance set to the current time. You can pass in strings representing the timezone and the locale -in the second and parameters, respectively. If no locale or timezone is provided, the application defaults will be used. +that returns a new instance set to the current time. You can pass in strings representing the timezone and locale +in the second and third parameters, respectively. If no locale or timezone is provided, the application defaults will be used. .. literalinclude:: time/003.php @@ -86,7 +86,7 @@ createFromDate() ================ Given separate inputs for **year**, **month**, and **day**, will return a new instance. If any of these parameters -are not provided, it will use the current value to fill it in. Accepts strings for the timezone and locale in the +are not provided, it will use the current year, month and day. Accepts strings for the timezone and locale in the fourth and fifth parameters: .. literalinclude:: time/008.php @@ -94,7 +94,7 @@ fourth and fifth parameters: createFromTime() ================ -Like ``createFromDate()`` except it is only concerned with the **hours**, **minutes**, and **seconds**. Uses the +Like ``createFromDate()``, except it is only concerned with the **hours**, **minutes**, and **seconds**. Uses the current day for the date portion of the Time instance. Accepts strings for the timezone and locale in the fourth and fifth parameters: @@ -104,7 +104,7 @@ create() ======== A combination of the previous two methods, takes **year**, **month**, **day**, **hour**, **minutes**, and **seconds** -as separate parameters. Any value not provided will use the current date and time to determine. Accepts strings for the +as separate parameters. Any value not provided will use the current date and time. Accepts strings for the timezone and locale in the fourth and fifth parameters: .. literalinclude:: time/010.php @@ -178,21 +178,21 @@ This will return a localized version of string formatted as (``Y-m-d H:i:s``): toDateString() ============== -Displays just the localized version of date portion of the Time: +Displays just the localized date portion of the Time: .. literalinclude:: time/017.php toTimeString() ============== -Displays just the localized version of time portion of the value: +Displays just the localized time portion of the value: .. literalinclude:: time/018.php humanize() ========== -This methods returns a string that displays the difference between the current date/time and the instance in a +This method returns a string that displays the difference between the current date/time and the instance in a human readable format that is geared towards being easily understood. It can create strings like '3 hours ago', 'in 1 month', etc: @@ -203,17 +203,18 @@ The exact time displayed is determined in the following manner: =============================== ================================= Time difference Result =============================== ================================= -$time > 1 year && < 2 years in 1 year / 1 year ago -$time > 1 month && < 1 year in 6 months / 6 months ago -$time > 7 days && < 1 month in 3 weeks / 3 weeks ago -$time > today && < 7 days in 4 days / 4 days ago -$time == tomorrow / yesterday Tomorrow / Yesterday -$time > 59 minutes && < 1 day in 2 hours / 2 hours ago -$time > now && < 1 hour in 35 minutes / 35 minutes ago +1 year < $time < 2 years in 1 year / 1 year ago +1 month < $time < 1 year in 6 months / 6 months ago +7 days < $time < 1 month in 3 weeks / 3 weeks ago +today < $time < 7 days in 4 days / 4 days ago +$time == yesterday / tomorrow Yesterday / Tomorrow +59 minutes < $time < 1 day in 2 hours / 2 hours ago +now < $time < 1 hour in 35 minutes / 35 minutes ago $time == now Now =============================== ================================= -The exact language used is controlled through the language file, **Time.php**. +The result strings are coming from the language file, **system/Language/en/Time.php**. +If you want to overwrite them, create **app/Language/{locale}/Time.php**. ****************************** Working with Individual Values @@ -240,7 +241,7 @@ In addition to these, a number of methods exist to provide additional informatio getAge() -------- -Returns the age, in years, of between the Time's instance and the current time. Perfect for checking +Returns the age, in years, between the Time instance and the current time. Perfect for checking the age of someone based on their birthday: .. literalinclude:: time/022.php @@ -402,7 +403,7 @@ humanize() Much like Time's ``humanize()`` method, this returns a string that displays the difference between the times in a human readable format that is geared towards being easily understood. It can create strings like '3 hours ago', -'in 1 month', etc. The biggest differences are in how very recent dates are handled: +'in 1 month', etc. The biggest difference is in how very recent dates are handled: .. literalinclude:: time/041.php @@ -411,13 +412,14 @@ The exact time displayed is determined in the following manner: =============================== ================================= Time difference Result =============================== ================================= -$time > 1 year && < 2 years in 1 year / 1 year ago -$time > 1 month && < 1 year in 6 months / 6 months ago -$time > 7 days && < 1 month in 3 weeks / 3 weeks ago -$time > today && < 7 days in 4 days / 4 days ago -$time > 1 hour && < 1 day in 8 hours / 8 hours ago -$time > 1 minute && < 1 hour in 35 minutes / 35 minutes ago +1 year < $time < 2 years in 1 year / 1 year ago +1 month < $time < 1 year in 6 months / 6 months ago +7 days < $time < 1 month in 3 weeks / 3 weeks ago +today < $time < 7 days in 4 days / 4 days ago +1 hour < $time < 1 day in 8 hours / 8 hours ago +1 minute < $time < 1 hour in 35 minutes / 35 minutes ago $time < 1 minute Now =============================== ================================= -The exact language used is controlled through the language file, **Time.php**. +The result strings are coming from the language file, **system/Language/en/Time.php**. +If you want to overwrite them, create **app/Language/{locale}/Time.php**.