Skip to content

Commit

Permalink
Merge pull request #3134 from briannesbitt/job/update-documentation
Browse files Browse the repository at this point in the history
Update documentation
  • Loading branch information
kylekatarnls authored Jan 15, 2025
2 parents 7fedd2f + b15b419 commit 7130c6d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
70 changes: 35 additions & 35 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ <h1 id="api-introduction">Introduction</h1>
$modifiedImmutable = CarbonImmutable::now()->add(1, 'day');

var_dump($modifiedMutable === $mutable); // bool(true)
var_dump($mutable->isoFormat('dddd D')); // string(12) "Wednesday 15"
var_dump($modifiedMutable->isoFormat('dddd D')); // string(12) "Wednesday 15"
var_dump($mutable->isoFormat('dddd D')); // string(11) "Thursday 16"
var_dump($modifiedMutable->isoFormat('dddd D')); // string(11) "Thursday 16"
// So it means $mutable and $modifiedMutable are the same object
// both set to now + 1 day.
var_dump($modifiedImmutable === $immutable); // bool(false)
var_dump($immutable->isoFormat('dddd D')); // string(10) "Tuesday 14"
var_dump($modifiedImmutable->isoFormat('dddd D')); // string(12) "Wednesday 15"
var_dump($immutable->isoFormat('dddd D')); // string(12) "Wednesday 15"
var_dump($modifiedImmutable->isoFormat('dddd D')); // string(11) "Thursday 16"
// While $immutable is still set to now and cannot be changed and
// $modifiedImmutable is a new instance created from $immutable
// set to now + 1 day.
Expand Down Expand Up @@ -281,16 +281,16 @@ <h1 id="api-instantiation">Instantiation</h1>

<p>
<pre class="live-editor"><code class="php">$now = Carbon::now();
echo $now; // 2025-01-14 01:03:37
echo $now; // 2025-01-15 00:21:14
echo "\n";
$today = Carbon::today();
echo $today; // 2025-01-14 00:00:00
echo $today; // 2025-01-15 00:00:00
echo "\n";
$tomorrow = Carbon::tomorrow('Europe/London');
echo $tomorrow; // 2025-01-15 00:00:00
echo $tomorrow; // 2025-01-16 00:00:00
echo "\n";
$yesterday = Carbon::yesterday();
echo $yesterday; // 2025-01-13 00:00:00
echo $yesterday; // 2025-01-14 00:00:00
</code></pre>
</p>

Expand Down Expand Up @@ -451,7 +451,7 @@ <h1 id="api-instantiation">Instantiation</h1>
// 19:15 in Johannesburg
echo 'Meeting starts at '.$meeting->format('H:i').' in Johannesburg.'; // Meeting starts at 19:15 in Johannesburg.
// now in Johannesburg
echo "It's ".$meeting->nowWithSameTz()->format('H:i').' right now in Johannesburg.'; // It's 03:03 right now in Johannesburg.
echo "It's ".$meeting->nowWithSameTz()->format('H:i').' right now in Johannesburg.'; // It's 02:21 right now in Johannesburg.
</code></pre>
</p>

Expand Down Expand Up @@ -705,7 +705,7 @@ <h1 id="api-localization">Localization</h1>
echo "\n";
echo $date->monthName; // janvier
echo "\n";
echo $date->isoFormat('LLLL'); // mardi 14 janvier 2025 01:03
echo $date->isoFormat('LLLL'); // mercredi 15 janvier 2025 00:21
</code></pre>
</p>

Expand Down Expand Up @@ -736,13 +736,13 @@ <h1 id="api-localization">Localization</h1>
echo $toDisplay;
/*
15 juin 2018 14:34
Aujourd’hui à 02:03
Aujourd’hui à 01:21
*/

echo $notificationForJohn;
/*
Jun 15, 2018 7:34 AM
Today at 7:03 PM
Today at 6:21 PM
*/
</code></pre>
</p>
Expand All @@ -769,9 +769,9 @@ <h1 id="api-localization">Localization</h1>
]);
// Important note: timezone setting calls ->shiftTimezone() and not ->setTimezone(),
// It means it does not just set the timezone, but shift the time too:
echo Carbon::today()->setTimezone('Asia/Tokyo')->format('d/m G\h e'); // 14/01 9h Asia/Tokyo
echo Carbon::today()->setTimezone('Asia/Tokyo')->format('d/m G\h e'); // 15/01 9h Asia/Tokyo
echo "\n";
echo Carbon::today()->shiftTimezone('Asia/Tokyo')->format('d/m G\h e'); // 14/01 0h Asia/Tokyo
echo Carbon::today()->shiftTimezone('Asia/Tokyo')->format('d/m G\h e'); // 15/01 0h Asia/Tokyo

// You can find back which factory created a given object:
$a = $factory->now();
Expand Down Expand Up @@ -1654,21 +1654,21 @@ <h1 id="api-localization">Localization</h1>

<p>
<pre class="live-editor"><code class="php">$date = CarbonImmutable::now();
echo $date->calendar(); // Today at 1:03 AM
echo $date->calendar(); // Today at 12:21 AM
echo "\n";
echo $date->sub('1 day 3 hours')->calendar(); // Last Sunday at 10:03 PM
echo $date->sub('1 day 3 hours')->calendar(); // Last Monday at 9:21 PM
echo "\n";
echo $date->sub('3 days 10 hours 23 minutes')->calendar(); // Last Friday at 2:40 PM
echo $date->sub('3 days 10 hours 23 minutes')->calendar(); // Last Saturday at 1:58 PM
echo "\n";
echo $date->sub('8 days')->calendar(); // 01/06/2025
echo $date->sub('8 days')->calendar(); // 01/07/2025
echo "\n";
echo $date->add('1 day 3 hours')->calendar(); // Tomorrow at 4:03 AM
echo $date->add('1 day 3 hours')->calendar(); // Tomorrow at 3:21 AM
echo "\n";
echo $date->add('3 days 10 hours 23 minutes')->calendar(); // Friday at 11:26 AM
echo $date->add('3 days 10 hours 23 minutes')->calendar(); // Saturday at 10:44 AM
echo "\n";
echo $date->add('8 days')->calendar(); // 01/22/2025
echo $date->add('8 days')->calendar(); // 01/23/2025
echo "\n";
echo $date->locale('fr')->calendar(); // Aujourd’hui à 01:03
echo $date->locale('fr')->calendar(); // Aujourd’hui à 00:21
</code></pre>
</p>

Expand Down Expand Up @@ -5588,7 +5588,7 @@ <h1 id="api-testing">Testing Aids</h1>
var_dump(Carbon::hasTestNow()); // bool(true)
Carbon::setTestNow(); // clear the mock
var_dump(Carbon::hasTestNow()); // bool(false)
echo Carbon::now(); // 2025-01-14 01:03:37
echo Carbon::now(); // 2025-01-15 00:21:15
// Instead of mock and clear mock, you also can use withTestNow():

Carbon::withTestNow('2010-09-15', static function () {
Expand Down Expand Up @@ -5831,12 +5831,12 @@ <h1 id="api-getters">Getters</h1>

// You can get any property dynamically too:
$unit = 'second';
var_dump(Carbon::now()->get($unit)); // int(37)
var_dump(Carbon::now()->get($unit)); // int(15)
// equivalent to:
var_dump(Carbon::now()->$unit); // int(37)
var_dump(Carbon::now()->$unit); // int(15)
// If you have plural unit name, use singularUnit()
$unit = Carbon::singularUnit('seconds');
var_dump(Carbon::now()->get($unit)); // int(37)
var_dump(Carbon::now()->get($unit)); // int(15)
// Prefer using singularUnit() because some plurals are not the word with S:
var_dump(Carbon::pluralUnit('century')); // string(9) "centuries"
var_dump(Carbon::pluralUnit('millennium')); // string(9) "millennia"
Expand Down Expand Up @@ -6413,8 +6413,8 @@ <h1 id="api-comparison">Comparison</h1>

// now is the default param
$dt1 = Carbon::createMidnightDate(2000, 1, 1);
echo $dt1->max(); // 2025-01-14 01:03:37
echo $dt1->maximum(); // 2025-01-14 01:03:37
echo $dt1->max(); // 2025-01-15 00:21:15
echo $dt1->maximum(); // 2025-01-15 00:21:15

// Remember min and max PHP native function work fine with dates too:
echo max(Carbon::create('2002-03-15'), Carbon::create('2003-01-07'), Carbon::create('2002-08-25')); // 2003-01-07 00:00:00
Expand Down Expand Up @@ -6909,7 +6909,7 @@ <h1 id="api-difference">Difference</h1>
greater than the other.</p>

<p>
<pre><code class="php">echo Carbon::now('America/Vancouver')->diffInSeconds(Carbon::now('Europe/London')); // 4.0E-6
<pre><code class="php">echo Carbon::now('America/Vancouver')->diffInSeconds(Carbon::now('Europe/London')); // 5.0E-6

$dtOttawa = Carbon::createMidnightDate(2000, 1, 1, 'America/Toronto');
$dtVancouver = Carbon::createMidnightDate(2000, 1, 1, 'America/Vancouver');
Expand Down Expand Up @@ -7048,10 +7048,10 @@ <h1 id="api-difference">Difference</h1>

$date = Carbon::now()->addSeconds(3666);

echo $date->diffInSeconds(); // -3665.999953
echo $date->diffInMinutes(); // -61.099998483333
echo $date->diffInHours(); // -1.0183332977778
echo $date->diffInDays(); // -0.042430553645833
echo $date->diffInSeconds(); // -3665.999949
echo $date->diffInMinutes(); // -61.099998383333
echo $date->diffInHours(); // -1.0183332961111
echo $date->diffInDays(); // -0.042430553599537

$date = Carbon::create(2016, 1, 5, 22, 40, 32);

Expand Down Expand Up @@ -7706,7 +7706,7 @@ <h1 id="api-macro">Macro</h1>
echo "\n";
echo Carbon::tomorrow()->formatForUser(); // Demain à 01:00
echo "\n";
echo Carbon::now()->subDays(3)->formatForUser(); // samedi dernier à 02:03
echo Carbon::now()->subDays(3)->formatForUser(); // dimanche dernier à 01:21
</code></pre>
</p>

Expand Down Expand Up @@ -8951,7 +8951,7 @@ <h1 id="api-period">CarbonPeriod</h1>
$days[] = $date->format('Y-m-d');
}

echo implode(', ', $days); // 2025-01-14, 2025-01-15, 2025-01-16
echo implode(', ', $days); // 2025-01-15, 2025-01-16, 2025-01-17
</code></pre>
</p>

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ <h2 id="backers">Backers</h2>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Dedicated tech job board for Germany (with transparent salaries)" href="https://germantechjobs.de/jobs/Java/All?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="GermanTechJobs" src="https://logo.clearbit.com/germantechjobs.de" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Salesforce" href="https://engineering.salesforce.com?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Salesforce" src="https://opencollective-production.s3.us-west-1.amazonaws.com/24d34880-df8d-11e9-949c-6bc2037b6bd5.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="People Search" href="https://identor.com/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="People Search" src="https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/1390e8dd-8742-49dd-b23b-2f2bca11cf51/identor-white-250-250-1.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="At TikTokFame, we take immense pride in our role as the premier platform for boosting TikTok engagement. Our expertise lies in enhancing likes." href="https://tiktokfame.co/buy-tiktok-followers/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="TikTokFame" src="https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/32ddc473-84f6-46df-8b5b-0fe04eedce2e/New%20Project%20(30).png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Helping people" href="https://glitteringgenerality.com?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="GlitteringGenerality" src="https://images.opencollective.com/glitteringgeneralityy/avatar/256.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Wagerbit" href="https://reddit.com/r/wagerbit?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Wagerbit" src="https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/b8b578f6-e292-4670-b904-b8c0da9a7350/Wagerbit%20reddit.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Sunset City Mushrooms" href="https://www.sunsetcity.ca/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Sunset City Mushrooms" src="https://logo.clearbit.com/www.sunsetcity.ca" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="At TikTokFame, we take immense pride in our role as the premier platform for boosting TikTok engagement. Our expertise lies in enhancing likes." href="https://tiktokfame.co/buy-tiktok-followers/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="TikTokFame" src="https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/32ddc473-84f6-46df-8b5b-0fe04eedce2e/New%20Project%20(30).png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Bishop Bettini" href="https://opencollective.com/bishop-bettini?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Bishop Bettini" src="https://images.opencollective.com/bishop-bettini/avatar/256.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Free and anonymous Instagram Story Viewer &amp; Downloader, you may see videos, pictures, and more from anybody you&#039;re interested in quietly and securely" href="https://insnoop.com/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Instagram Story Viewer" src="https://images.opencollective.com/insta-story-viewer/avatar/256.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Alberto Fortin" href="https://opencollective.com/guest-e9c3a9c8?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Alberto Fortin" src="https://images.opencollective.com/guest-e9c3a9c8/avatar/256.png" width="24" height="24"></a>
Expand Down

0 comments on commit 7130c6d

Please sign in to comment.