Skip to content

Commit 48b4a99

Browse files
authored
Merge pull request #5431 from kenjis/fix-docs-time.rst
docs: fix time.rst
2 parents 8abc2f0 + f55ddd2 commit 48b4a99

1 file changed

Lines changed: 56 additions & 56 deletions

File tree

user_guide_src/source/libraries/time.rst

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Times and Dates
44

55
CodeIgniter provides a fully-localized, immutable, date/time class that is built on PHP's DateTime object, but uses the Intl
66
extension's features to convert times across timezones and display the output correctly for different locales. This class
7-
is the **Time** class and lives in the **CodeIgniter\\I18n** namespace.
7+
is the ``Time`` class and lives in the ``CodeIgniter\I18n`` namespace.
88

99
.. note:: Since the Time class extends DateTime, if there are features that you need that this class doesn't provide,
1010
you can likely find them within the DateTime class itself.
@@ -38,7 +38,7 @@ provided, the application defaults will be used.
3838
now()
3939
-----
4040

41-
The Time class has several helper methods to instantiate the class. The first of these is the **now()** method
41+
The Time class has several helper methods to instantiate the class. The first of these is the ``now()`` method
4242
that returns a new instance set to the current time. You can pass in strings representing the timezone and the locale
4343
in the second and parameters, respectively. If no locale or timezone is provided, the application defaults will be used.
4444

@@ -85,18 +85,18 @@ Given separate inputs for **year**, **month**, and **day**, will return a new in
8585
are not provided, it will use the current value to fill it in. Accepts strings for the timezone and locale in the
8686
fourth and fifth parameters::
8787

88-
$today = Time::createFromDate(); // Uses current year, month, and day
88+
$today = Time::createFromDate(); // Uses current year, month, and day
8989
$anniversary = Time::createFromDate(2018); // Uses current month and day
9090
$date = Time::createFromDate(2018, 3, 15, 'America/Chicago', 'en_US');
9191

9292
createFromTime()
9393
----------------
9494

95-
Like **createFromDate** except it is only concerned with the **hours**, **minutes**, and **seconds**. Uses the
95+
Like ``createFromDate()`` except it is only concerned with the **hours**, **minutes**, and **seconds**. Uses the
9696
current day for the date portion of the Time instance. Accepts strings for the timezone and locale in the
9797
fourth and fifth parameters::
9898

99-
$lunch = Time::createFromTime(11, 30); // 11:30 am today
99+
$lunch = Time::createFromTime(11, 30); // 11:30 am today
100100
$dinner = Time::createFromTime(18, 00, 00); // 6:00 pm today
101101
$time = Time::createFromTime($hour, $minutes, $seconds, $timezone, $locale);
102102

@@ -113,7 +113,7 @@ createFromFormat()
113113
------------------
114114

115115
This is a replacement for DateTime's method of the same name. This allows the timezone to be set at the same time,
116-
and returns a **Time** instance, instead of DateTime::
116+
and returns a ``Time`` instance, instead of DateTime::
117117

118118
$time = Time::createFromFormat('j-M-Y', '15-Feb-2009', 'America/Chicago');
119119

@@ -154,7 +154,7 @@ to display localized versions of the value, though.
154154
toLocalizedString()
155155
-------------------
156156

157-
This is the localized version of DateTime's format() method. Instead of using the values you might be familiar with, though,
157+
This is the localized version of DateTime's ``format()`` method. Instead of using the values you might be familiar with, though,
158158
you must use values acceptable to the `IntlDateFormatter <https://www.php.net/manual/en/class.intldateformatter.php>`__ class.
159159
A full listing of values can be found `here <https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classSimpleDateFormat.html#details>`__.
160160
::
@@ -214,7 +214,7 @@ $time > now && < 1 hour in 35 minutes / 35 minutes ago
214214
$time == now Now
215215
=============================== =================================
216216

217-
The exact language used is controlled through the language file, Time.php.
217+
The exact language used is controlled through the language file, **Time.php**.
218218

219219
==============================
220220
Working with Individual Values
@@ -224,8 +224,8 @@ The Time object provides a number of methods to allow to get and set individual
224224
of an existing instance. All of the values retrieved through the following methods will be fully localized and respect
225225
the locale that the Time instance was created with.
226226

227-
All of the following `getX` and `setX` methods can also be used as if they were a class property. So, any calls to methods
228-
like `getYear` can also be accessed through `$time->year`, and so on.
227+
All of the following ``getX()`` and ``setX()`` methods can also be used as if they were a class property. So, any calls to methods
228+
like ``getYear()`` can also be accessed through ``$time->year``, and so on.
229229

230230
Getters
231231
-------
@@ -234,37 +234,37 @@ The following basic getters exist::
234234

235235
$time = Time::parse('August 12, 2016 4:15:23pm');
236236

237-
echo $time->getYear(); // 2016
238-
echo $time->getMonth(); // 8
239-
echo $time->getDay(); // 12
240-
echo $time->getHour(); // 16
237+
echo $time->getYear(); // 2016
238+
echo $time->getMonth(); // 8
239+
echo $time->getDay(); // 12
240+
echo $time->getHour(); // 16
241241
echo $time->getMinute(); // 15
242242
echo $time->getSecond(); // 23
243243

244-
echo $time->year; // 2016
245-
echo $time->month; // 8
246-
echo $time->day; // 12
247-
echo $time->hour; // 16
244+
echo $time->year; // 2016
245+
echo $time->month; // 8
246+
echo $time->day; // 12
247+
echo $time->hour; // 16
248248
echo $time->minute; // 15
249249
echo $time->second; // 23
250250

251251
In addition to these, a number of methods exist to provide additional information about the date::
252252

253253
$time = Time::parse('August 12, 2016 4:15:23pm');
254254

255-
echo $time->getDayOfWeek(); // 6 - but may vary based on locale's starting day of the week
256-
echo $time->getDayOfYear(); // 225
255+
echo $time->getDayOfWeek(); // 6 - but may vary based on locale's starting day of the week
256+
echo $time->getDayOfYear(); // 225
257257
echo $time->getWeekOfMonth(); // 2
258-
echo $time->getWeekOfYear(); // 33
259-
echo $time->getTimestamp(); // 1471018523 - UNIX timestamp
260-
echo $time->getQuarter(); // 3
258+
echo $time->getWeekOfYear(); // 33
259+
echo $time->getTimestamp(); // 1471018523 - UNIX timestamp
260+
echo $time->getQuarter(); // 3
261261

262-
echo $time->dayOfWeek; // 6
263-
echo $time->dayOfYear; // 225
262+
echo $time->dayOfWeek; // 6
263+
echo $time->dayOfYear; // 225
264264
echo $time->weekOfMonth; // 2
265-
echo $time->weekOfYear; // 33
266-
echo $time->timestamp; // 1471018523
267-
echo $time->quarter; // 3
265+
echo $time->weekOfYear; // 33
266+
echo $time->timestamp; // 1471018523
267+
echo $time->quarter; // 3
268268

269269
getAge()
270270
--------
@@ -275,22 +275,22 @@ the age of someone based on their birthday::
275275
$time = Time::parse('5 years ago');
276276

277277
echo $time->getAge(); // 5
278-
echo $time->age; // 5
278+
echo $time->age; // 5
279279

280280
getDST()
281281
--------
282282

283283
Returns boolean true/false based on whether the Time instance is currently observing Daylight Savings Time::
284284

285285
echo Time::createFromDate(2012, 1, 1)->getDst(); // false
286-
echo Time::createFromDate(2012, 9, 1)->dst; // true
286+
echo Time::createFromDate(2012, 9, 1)->dst; // true
287287

288288
getLocal()
289289
----------
290290

291291
Returns boolean true if the Time instance is in the same timezone as the application is currently running in::
292292

293-
echo Time::now()->getLocal(); // true
293+
echo Time::now()->getLocal(); // true
294294
echo Time::now('Europe/London'); // false
295295

296296
getUtc()
@@ -299,7 +299,7 @@ getUtc()
299299
Returns boolean true if the Time instance is in UTC time::
300300

301301
echo Time::now('America/Chicago')->getUtc(); // false
302-
echo Time::now('UTC')->utc; // true
302+
echo Time::now('UTC')->utc; // true
303303

304304
getTimezone()
305305
-------------
@@ -319,7 +319,7 @@ getTimezoneName()
319319
Returns the full `timezone string <https://www.php.net/manual/en/timezones.php>`__ of the Time instance::
320320

321321
echo Time::now('America/Chicago')->getTimezoneName(); // America/Chicago
322-
echo Time::now('Europe/London')->timezoneName; // Europe/London
322+
echo Time::now('Europe/London')->timezoneName; // Europe/London
323323

324324
Setters
325325
=======
@@ -334,11 +334,11 @@ thrown.
334334
::
335335

336336
$time = $time->setYear(2017);
337-
$time = $time->setMonthNumber(4); // April
338-
$time = $time->setMonthLongName('April');
339-
$time = $time->setMonthShortName('Feb'); // February
337+
$time = $time->setMonth(4); // April
338+
$time = $time->setMonth('April');
339+
$time = $time->setMonth('Feb'); // February
340340
$time = $time->setDay(25);
341-
$time = $time->setHour(14); // 2:00 pm
341+
$time = $time->setHour(14); // 2:00 pm
342342
$time = $time->setMinute(30);
343343
$time = $time->setSecond(54);
344344

@@ -350,10 +350,10 @@ Converts the time from it's current timezone into the new one::
350350
$time = Time::parse('13 May 2020 10:00', 'America/Chicago');
351351
$time2 = $time->setTimezone('Europe/London'); // Returns new instance converted to new timezone
352352

353-
echo $time->getTimezoneName(); // American/Chicago
353+
echo $time->getTimezoneName(); // American/Chicago
354354
echo $time2->getTimezoneName(); // Europe/London
355355

356-
echo $time->toDateTimeString(); // 2020-05-13 10:00:00
356+
echo $time->toDateTimeString(); // 2020-05-13 10:00:00
357357
echo $time2->toDateTimeString(); // 2020-05-13 18:00:00
358358

359359
setTimestamp()
@@ -364,7 +364,7 @@ Returns a new instance with the date set to the new timestamp::
364364
$time = Time::parse('May 10, 2017', 'America/Chicago');
365365
$time2 = $time->setTimestamp(strtotime('April 1, 2017'));
366366

367-
echo $time->toDateTimeString(); // 2017-05-10 00:00:00
367+
echo $time->toDateTimeString(); // 2017-05-10 00:00:00
368368
echo $time2->toDateTimeString(); // 2017-04-01 00:00:00
369369

370370
Modifying the Value
@@ -416,13 +416,13 @@ a timezone string in as the second parameter. If no timezone is given, the syste
416416
sameAs()
417417
--------
418418

419-
This is identical to the **equals** method, except that it only returns true when the date, time, AND timezone are
419+
This is identical to the ``equals()`` method, except that it only returns true when the date, time, AND timezone are
420420
all identical::
421421

422422
$time1 = Time::parse('January 10, 2017 21:50:00', 'America/Chicago');
423423
$time2 = Time::parse('January 11, 2017 03:50:00', 'Europe/London');
424424

425-
$time1->sameAs($time2); // false
425+
$time1->sameAs($time2); // false
426426
$time2->sameAs('January 10, 2017 21:50:00', 'America/Chicago'); // true
427427

428428
isBefore()
@@ -446,7 +446,7 @@ a timezone string in as the second parameter. If no timezone is given, the syste
446446
isAfter()
447447
---------
448448

449-
Works exactly the same as **isBefore()** except checks if the time is after the time passed in::
449+
Works exactly the same as ``isBefore()`` except checks if the time is after the time passed in::
450450

451451
$time1 = Time::parse('January 10, 2017 21:50:00', 'America/Chicago');
452452
$time2 = Time::parse('January 11, 2017 03:50:00', 'America/Chicago');
@@ -457,7 +457,7 @@ Works exactly the same as **isBefore()** except checks if the time is after the
457457
Viewing Differences
458458
===================
459459

460-
To compare two Times directly, you would use the **difference()** method, which returns a **CodeIgniter\\I18n\\TimeDifference**
460+
To compare two Times directly, you would use the ``difference()`` method, which returns a ``CodeIgniter\I18n\TimeDifference``
461461
instance. The first parameter is either a Time instance, a DateTime instance, or a string with the date/time. If
462462
a string is passed in the first parameter, the second parameter can be a timezone string::
463463

@@ -476,28 +476,28 @@ the original time::
476476

477477
$diff = $current->difference($test);
478478

479-
echo $diff->getYears(); // -7
480-
echo $diff->getMonths(); // -84
481-
echo $diff->getWeeks(); // -365
482-
echo $diff->getDays(); // -2557
483-
echo $diff->getHours(); // -61368
479+
echo $diff->getYears(); // -7
480+
echo $diff->getMonths(); // -84
481+
echo $diff->getWeeks(); // -365
482+
echo $diff->getDays(); // -2557
483+
echo $diff->getHours(); // -61368
484484
echo $diff->getMinutes(); // -3682080
485485
echo $diff->getSeconds(); // -220924800
486486

487-
You can use either **getX()** methods, or access the calculate values as if they were properties::
487+
You can use either ``getX()`` methods, or access the calculate values as if they were properties::
488488

489489
echo $diff->years; // -7
490-
echo $diff->months; // -84
491-
echo $diff->weeks; // -365
492-
echo $diff->days; // -2557
493-
echo $diff->hours; // -61368
490+
echo $diff->months; // -84
491+
echo $diff->weeks; // -365
492+
echo $diff->days; // -2557
493+
echo $diff->hours; // -61368
494494
echo $diff->minutes; // -3682080
495495
echo $diff->seconds; // -220924800
496496

497497
humanize()
498498
----------
499499

500-
Much like Time's humanize() method, this returns a string that displays the difference between the times in a
500+
Much like Time's ``humanize()`` method, this returns a string that displays the difference between the times in a
501501
human readable format that is geared towards being easily understood. It can create strings like '3 hours ago',
502502
'in 1 month', etc. The biggest differences are in how very recent dates are handled::
503503

@@ -522,4 +522,4 @@ $time > 1 minute && < 1 hour in 35 minutes / 35 minutes ago
522522
$time < 1 minute Now
523523
=============================== =================================
524524

525-
The exact language used is controlled through the language file, Time.php.
525+
The exact language used is controlled through the language file, **Time.php**.

0 commit comments

Comments
 (0)