@@ -13,9 +13,9 @@ is the ``Time`` class and lives in the ``CodeIgniter\I18n`` namespace.
1313 :local:
1414 :depth: 2
1515
16- =============
16+ *************
1717Instantiating
18- =============
18+ *************
1919
2020There are several ways that a new Time instance can be created. The first is simply to create a new instance
2121like any other class. When you do it this way, you can pass in a string representing the desired time. This can
@@ -31,7 +31,7 @@ provided, the application defaults will be used.
3131.. literalinclude :: time/002.php
3232
3333now()
34- -----
34+ =====
3535
3636The Time class has several helper methods to instantiate the class. The first of these is the ``now() `` method
3737that returns a new instance set to the current time. You can pass in strings representing the timezone and the locale
@@ -40,39 +40,39 @@ in the second and parameters, respectively. If no locale or timezone is provided
4040.. literalinclude :: time/003.php
4141
4242parse()
43- -------
43+ =======
4444
4545This helper method is a static version of the default constructor. It takes a string acceptable as DateTime's
4646constructor as the first parameter, a timezone as the second parameter, and the locale as the third parameter:
4747
4848.. literalinclude :: time/004.php
4949
5050today()
51- -------
51+ =======
5252
5353Returns a new instance with the date set to the current date, and the time set to midnight. It accepts strings
5454for the timezone and locale in the first and second parameters:
5555
5656.. literalinclude :: time/005.php
5757
5858yesterday()
59- -----------
59+ ===========
6060
6161Returns a new instance with the date set to the yesterday's date and the time set to midnight. It accepts strings
6262for the timezone and locale in the first and second parameters:
6363
6464.. literalinclude :: time/006.php
6565
6666tomorrow()
67- -----------
67+ ==========
6868
6969Returns a new instance with the date set to tomorrow's date and the time set to midnight. It accepts strings
7070for the timezone and locale in the first and second parameters:
7171
7272.. literalinclude :: time/007.php
7373
7474createFromDate()
75- ----------------
75+ ================
7676
7777Given separate inputs for **year **, **month **, and **day **, will return a new instance. If any of these parameters
7878are not provided, it will use the current value to fill it in. Accepts strings for the timezone and locale in the
@@ -81,7 +81,7 @@ fourth and fifth parameters:
8181.. literalinclude :: time/008.php
8282
8383createFromTime()
84- ----------------
84+ ================
8585
8686Like ``createFromDate() `` except it is only concerned with the **hours **, **minutes **, and **seconds **. Uses the
8787current day for the date portion of the Time instance. Accepts strings for the timezone and locale in the
@@ -90,7 +90,7 @@ fourth and fifth parameters:
9090.. literalinclude :: time/009.php
9191
9292create()
93- --------
93+ ========
9494
9595A combination of the previous two methods, takes **year **, **month **, **day **, **hour **, **minutes **, and **seconds **
9696as separate parameters. Any value not provided will use the current date and time to determine. Accepts strings for the
@@ -99,22 +99,22 @@ timezone and locale in the fourth and fifth parameters:
9999.. literalinclude :: time/010.php
100100
101101createFromFormat()
102- ------------------
102+ ==================
103103
104104This is a replacement for DateTime's method of the same name. This allows the timezone to be set at the same time,
105105and returns a ``Time `` instance, instead of DateTime:
106106
107107.. literalinclude :: time/011.php
108108
109109createFromTimestamp()
110- ---------------------
110+ =====================
111111
112112This method takes a UNIX timestamp and, optionally, the timezone and locale, to create a new Time instance:
113113
114114.. literalinclude :: time/012.php
115115
116116createFromInstance()
117- --------------------
117+ ====================
118118
119119When working with other libraries that provide a DateTime instance, you can use this method to convert that
120120to a Time instance, optionally setting the locale. The timezone will be automatically determined from the DateTime
@@ -123,24 +123,25 @@ instance passed in:
123123.. literalinclude :: time/013.php
124124
125125toDateTime()
126- ------------
126+ ============
127127
128128While not an instantiator, this method is the opposite of the **instance ** method, allowing you to convert a Time
129129instance into a DateTime instance. This preserves the timezone setting, but loses the locale, since DateTime is
130130not aware of locales:
131131
132132.. literalinclude :: time/014.php
133133
134- ====================
134+
135+ ********************
135136Displaying the Value
136- ====================
137+ ********************
137138
138139Since the Time class extends DateTime, you get all of the output methods that provides, including the format() method.
139140However, the DateTime methods do not provide a localized result. The Time class does provide a number of helper methods
140141to display localized versions of the value, though.
141142
142143toLocalizedString()
143- -------------------
144+ ===================
144145
145146This is the localized version of DateTime's ``format() `` method. Instead of using the values you might be familiar with, though,
146147you must use values acceptable to the `IntlDateFormatter <https://www.php.net/manual/en/class.intldateformatter.php >`__ class.
@@ -149,29 +150,29 @@ A full listing of values can be found `here <https://unicode-org.github.io/icu-d
149150.. literalinclude :: time/015.php
150151
151152toDateTimeString()
152- ------------------
153+ ==================
153154
154155This is the first of three helper methods to work with the IntlDateFormatter without having to remember their values.
155156This will return a string formatted as you would commonly use for datetime columns in a database (Y-m-d H:i: s):
156157
157158.. literalinclude :: time/016.php
158159
159160toDateString()
160- --------------
161+ ==============
161162
162163Displays just the date portion of the Time:
163164
164165.. literalinclude :: time/017.php
165166
166167toTimeString()
167- --------------
168+ ==============
168169
169170Displays just the time portion of the value:
170171
171172.. literalinclude :: time/018.php
172173
173174humanize()
174- ----------
175+ ==========
175176
176177This methods returns a string that displays the difference between the current date/time and the instance in a
177178human readable format that is geared towards being easily understood. It can create strings like '3 hours ago',
@@ -196,9 +197,9 @@ $time == now Now
196197
197198The exact language used is controlled through the language file, **Time.php **.
198199
199- ==============================
200+ ******************************
200201Working with Individual Values
201- ==============================
202+ ******************************
202203
203204The Time object provides a number of methods to allow to get and set individual items, like the year, month, hour, etc,
204205of an existing instance. All of the values retrieved through the following methods will be fully localized and respect
@@ -208,7 +209,7 @@ All of the following ``getX()`` and ``setX()`` methods can also be used as if th
208209like ``getYear() `` can also be accessed through ``$time->year ``, and so on.
209210
210211Getters
211- -------
212+ =======
212213
213214The following basic getters exist:
214215
0 commit comments