22Times and Dates
33###############
44
5- CodeIgniter provides a fully-localized, immutable, date/time class that is built on PHP's DateTimeImmutable object , but uses the Intl
5+ CodeIgniter provides a fully-localized, immutable, date/time class that is built on PHP's DateTimeImmutable class , but uses the Intl
66extension's features to convert times across timezones and display the output correctly for different locales. This class
77is the ``Time `` class and lives in the ``CodeIgniter\I18n `` namespace.
88
@@ -34,9 +34,9 @@ This can be any string that PHP's `DateTimeImmutable`_ constructor can parse. Se
3434
3535.. literalinclude :: time/001.php
3636
37- You can pass in strings representing the timezone and the locale in the second and parameters, respectively. Timezones
38- can be any supported by PHP's `DateTimeZone <https://www.php.net/manual/en/timezones.php >`__ class. The locale can be
39- any supported by PHP's `Locale <https://www.php.net/manual/en/class.locale.php >`__ class. If no locale or timezone is
37+ You can pass in strings representing the timezone and the locale in the second and the third parameters, respectively. The timezone
38+ can be any one supported by PHP's `DateTimeZone <https://www.php.net/manual/en/timezones.php >`__ class. The locale can be
39+ any one supported by PHP's `Locale <https://www.php.net/manual/en/class.locale.php >`__ class. If no locale or timezone is
4040provided, the application defaults will be used.
4141
4242.. literalinclude :: time/002.php
4545=====
4646
4747The Time class has several helper methods to instantiate the class. The first of these is the ``now() `` method
48- that returns a new instance set to the current time. You can pass in strings representing the timezone and the locale
49- in the second and parameters, respectively. If no locale or timezone is provided, the application defaults will be used.
48+ that returns a new instance set to the current time. You can pass in strings representing the timezone and locale
49+ in the second and third parameters, respectively. If no locale or timezone is provided, the application defaults will be used.
5050
5151.. literalinclude :: time/003.php
5252
@@ -86,15 +86,15 @@ createFromDate()
8686================
8787
8888Given separate inputs for **year **, **month **, and **day **, will return a new instance. If any of these parameters
89- are not provided, it will use the current value to fill it in . Accepts strings for the timezone and locale in the
89+ are not provided, it will use the current year, month and day . Accepts strings for the timezone and locale in the
9090fourth and fifth parameters:
9191
9292.. literalinclude :: time/008.php
9393
9494createFromTime()
9595================
9696
97- Like ``createFromDate() `` except it is only concerned with the **hours **, **minutes **, and **seconds **. Uses the
97+ Like ``createFromDate() ``, except it is only concerned with the **hours **, **minutes **, and **seconds **. Uses the
9898current day for the date portion of the Time instance. Accepts strings for the timezone and locale in the
9999fourth and fifth parameters:
100100
@@ -104,7 +104,7 @@ create()
104104========
105105
106106A combination of the previous two methods, takes **year **, **month **, **day **, **hour **, **minutes **, and **seconds **
107- as separate parameters. Any value not provided will use the current date and time to determine . Accepts strings for the
107+ as separate parameters. Any value not provided will use the current date and time. Accepts strings for the
108108timezone and locale in the fourth and fifth parameters:
109109
110110.. literalinclude :: time/010.php
@@ -178,21 +178,21 @@ This will return a localized version of string formatted as (``Y-m-d H:i:s``):
178178toDateString()
179179==============
180180
181- Displays just the localized version of date portion of the Time:
181+ Displays just the localized date portion of the Time:
182182
183183.. literalinclude :: time/017.php
184184
185185toTimeString()
186186==============
187187
188- Displays just the localized version of time portion of the value:
188+ Displays just the localized time portion of the value:
189189
190190.. literalinclude :: time/018.php
191191
192192humanize()
193193==========
194194
195- This methods returns a string that displays the difference between the current date/time and the instance in a
195+ This method returns a string that displays the difference between the current date/time and the instance in a
196196human readable format that is geared towards being easily understood. It can create strings like '3 hours ago',
197197'in 1 month', etc:
198198
@@ -203,17 +203,17 @@ The exact time displayed is determined in the following manner:
203203=============================== =================================
204204Time difference Result
205205=============================== =================================
206- $time > 1 year && < 2 years in 1 year / 1 year ago
207- $time > 1 month && < 1 year in 6 months / 6 months ago
208- $time > 7 days && < 1 month in 3 weeks / 3 weeks ago
209- $time > today && < 7 days in 4 days / 4 days ago
210- $time == tomorrow / yesterday Tomorrow / Yesterday
211- $time > 59 minutes && < 1 day in 2 hours / 2 hours ago
212- $time > now && < 1 hour in 35 minutes / 35 minutes ago
206+ 1 year < $time < 2 years in 1 year / 1 year ago
207+ 1 month < $time < 1 year in 6 months / 6 months ago
208+ 7 days < $time < 1 month in 3 weeks / 3 weeks ago
209+ today < $time < 7 days in 4 days / 4 days ago
210+ $time == yesterday / tomorrow Yesterday / Tomorrow
211+ 59 minutes < $time < 1 day in 2 hours / 2 hours ago
212+ now < $time < 1 hour in 35 minutes / 35 minutes ago
213213$time == now Now
214214=============================== =================================
215215
216- The exact language used is controlled through the language file, **Time.php **.
216+ The result strings are coming from the language file, **app/Language/{locale}/ Time.php **.
217217
218218******************************
219219Working with Individual Values
@@ -240,7 +240,7 @@ In addition to these, a number of methods exist to provide additional informatio
240240getAge()
241241--------
242242
243- Returns the age, in years, of between the Time's instance and the current time. Perfect for checking
243+ Returns the age, in years, between the Time instance and the current time. Perfect for checking
244244the age of someone based on their birthday:
245245
246246.. literalinclude :: time/022.php
@@ -402,7 +402,7 @@ humanize()
402402
403403Much like Time's ``humanize() `` method, this returns a string that displays the difference between the times in a
404404human readable format that is geared towards being easily understood. It can create strings like '3 hours ago',
405- 'in 1 month', etc. The biggest differences are in how very recent dates are handled:
405+ 'in 1 month', etc. The biggest difference is in how very recent dates are handled:
406406
407407.. literalinclude :: time/041.php
408408
@@ -411,13 +411,13 @@ The exact time displayed is determined in the following manner:
411411=============================== =================================
412412Time difference Result
413413=============================== =================================
414- $time > 1 year && < 2 years in 1 year / 1 year ago
415- $time > 1 month && < 1 year in 6 months / 6 months ago
416- $time > 7 days && < 1 month in 3 weeks / 3 weeks ago
417- $time > today && < 7 days in 4 days / 4 days ago
418- $time > 1 hour && < 1 day in 8 hours / 8 hours ago
419- $time > 1 minute && < 1 hour in 35 minutes / 35 minutes ago
414+ 1 year < $time < 2 years in 1 year / 1 year ago
415+ 1 month < $time < 1 year in 6 months / 6 months ago
416+ 7 days < $time < 1 month in 3 weeks / 3 weeks ago
417+ today < $time < 7 days in 4 days / 4 days ago
418+ 1 hour < $time < 1 day in 8 hours / 8 hours ago
419+ 1 minute < $time < 1 hour in 35 minutes / 35 minutes ago
420420$time < 1 minute Now
421421=============================== =================================
422422
423- The exact language used is controlled through the language file, **Time.php **.
423+ The result strings are coming from the language file, **app/Language/{locale}/ Time.php **.
0 commit comments