Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
# Carbon
2
 
3
[![Latest Stable Version](https://img.shields.io/packagist/v/nesbot/carbon.svg?style=flat-square)](https://packagist.org/packages/nesbot/carbon)
4
[![Total Downloads](https://img.shields.io/packagist/dt/nesbot/carbon.svg?style=flat-square)](https://packagist.org/packages/nesbot/carbon)
5
[![GitHub Actions](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fbriannesbitt%2FCarbon%2Fbadge&style=flat-square&label=Build&logo=none)](https://actions-badge.atrox.dev/briannesbitt/Carbon/goto)
6
[![codecov.io](https://img.shields.io/codecov/c/github/briannesbitt/Carbon.svg?style=flat-square)](https://codecov.io/github/briannesbitt/Carbon?branch=master)
7
[![Tidelift](https://tidelift.com/badges/github/briannesbitt/Carbon)](https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme)
8
 
9
An international PHP extension for DateTime. [https://carbon.nesbot.com](https://carbon.nesbot.com)
10
 
11
```php
12
<?php
13
 
14
use Carbon\Carbon;
15
 
16
printf("Right now is %s", Carbon::now()->toDateTimeString());
17
printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver'));  //implicit __toString()
18
$tomorrow = Carbon::now()->addDay();
19
$lastWeek = Carbon::now()->subWeek();
20
$nextSummerOlympics = Carbon::createFromDate(2016)->addYears(4);
21
 
22
$officialDate = Carbon::now()->toRfc2822String();
23
 
24
$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;
25
 
26
$noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London');
27
 
28
$internetWillBlowUpOn = Carbon::create(2038, 01, 19, 3, 14, 7, 'GMT');
29
 
30
// Don't really want this to happen so mock now
31
Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));
32
 
33
// comparisons are always done in UTC
34
if (Carbon::now()->gte($internetWillBlowUpOn)) {
35
    die();
36
}
37
 
38
// Phew! Return to normal behaviour
39
Carbon::setTestNow();
40
 
41
if (Carbon::now()->isWeekend()) {
42
    echo 'Party!';
43
}
44
// Over 200 languages (and over 500 regional variants) supported:
45
echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago'
46
echo Carbon::now()->subMinutes(2)->locale('zh_CN')->diffForHumans(); // '2分钟前'
47
echo Carbon::parse('2019-07-23 14:51')->isoFormat('LLLL'); // 'Tuesday, July 23, 2019 2:51 PM'
48
echo Carbon::parse('2019-07-23 14:51')->locale('fr_FR')->isoFormat('LLLL'); // 'mardi 23 juillet 2019 14:51'
49
 
50
// ... but also does 'from now', 'after' and 'before'
51
// rolling up to seconds, minutes, hours, days, months, years
52
 
53
$daysSinceEpoch = Carbon::createFromTimestamp(0)->diffInDays();
54
```
55
 
56
[Get supported nesbot/carbon with the Tidelift Subscription](https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme)
57
 
58
## Installation
59
 
60
### With Composer
61
 
62
```
63
$ composer require nesbot/carbon
64
```
65
 
66
```json
67
{
68
    "require": {
69
        "nesbot/carbon": "^2.16"
70
    }
71
}
72
```
73
 
74
```php
75
<?php
76
require 'vendor/autoload.php';
77
 
78
use Carbon\Carbon;
79
 
80
printf("Now: %s", Carbon::now());
81
```
82
 
83
### Without Composer
84
 
85
Why are you not using [composer](https://getcomposer.org/)? Download the Carbon [latest release](https://github.com/briannesbitt/Carbon/releases) and put the contents of the ZIP archive into a directory in your project. Then require the file `autoload.php` to get all classes and dependencies loaded on need.
86
 
87
```php
88
<?php
89
require 'path-to-Carbon-directory/autoload.php';
90
 
91
use Carbon\Carbon;
92
 
93
printf("Now: %s", Carbon::now());
94
```
95
 
96
## Docs
97
 
98
[https://carbon.nesbot.com/docs](https://carbon.nesbot.com/docs)
99
 
100
## Security contact information
101
 
102
To report a security vulnerability, please use the
103
[Tidelift security contact](https://tidelift.com/security).
104
Tidelift will coordinate the fix and disclosure.
105
 
106
## Credits
107
 
108
### Contributors
109
 
110
This project exists thanks to all the people who contribute.
111
 
112
<a href="https://github.com/briannesbitt/Carbon/graphs/contributors" target="_blank"><img src="https://opencollective.com/Carbon/contributors.svg?width=890&button=false" /></a>
113
 
114
### Translators
115
 
116
[Thanks to people helping us to translate Carbon in so many languages](https://carbon.nesbot.com/contribute/translators/)
117
 
118
### Sponsors
119
 
120
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
121
 
122
<a href="https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme" target="_blank"><img src="https://carbon.nesbot.com/tidelift-brand.png" width="256" height="64"></a>
123
<a href="https://casinohex.org/canada/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img src="https://images.opencollective.com/hexcasinoca/2da3af2/logo/256.png" width="85" height="64"></a>
124
 
125
<a href="https://github.com/taylorotwell" target="_blank"><img src="https://avatars.githubusercontent.com/u/463230?s=128&v=4" width="64" height="64"></a>
126
<a href="https://github.com/usefathom" target="_blank"><img src="https://avatars.githubusercontent.com/u/38684088?s=128&v=4" width="64" height="64"></a>
127
<a href="https://github.com/tobischulz" target="_blank"><img src="https://avatars.githubusercontent.com/u/576014?s=128&v=4" width="64" height="64"></a>
128
<a href="https://w3guy.com/" target="_blank"><img src="https://avatars.githubusercontent.com/u/4140659?v=4" width="64" height="64"></a>
129
 
130
<a href="https://opencollective.com/Carbon/sponsor/0/website" target="_blank"><img src="https://opencollective.com/Carbon/sponsor/0/avatar.svg"></a>
131
<a href="https://opencollective.com/Carbon/sponsor/1/website" target="_blank"><img src="https://opencollective.com/Carbon/sponsor/1/avatar.svg"></a>
132
<a href="https://opencollective.com/Carbon/sponsor/2/website" target="_blank"><img src="https://opencollective.com/Carbon/sponsor/2/avatar.svg"></a>
133
<a href="https://opencollective.com/Carbon/sponsor/3/website" target="_blank"><img src="https://opencollective.com/Carbon/sponsor/3/avatar.svg"></a>
134
<a href="https://opencollective.com/Carbon/sponsor/4/website" target="_blank"><img src="https://opencollective.com/Carbon/sponsor/4/avatar.svg"></a>
135
<a href="https://opencollective.com/Carbon/sponsor/5/website" target="_blank"><img src="https://opencollective.com/Carbon/sponsor/5/avatar.svg"></a>
136
<a href="https://opencollective.com/Carbon/sponsor/6/website" target="_blank"><img src="https://opencollective.com/Carbon/sponsor/6/avatar.svg"></a>
137
<a href="https://opencollective.com/Carbon/sponsor/7/website" target="_blank"><img src="https://opencollective.com/Carbon/sponsor/7/avatar.svg"></a>
138
<a href="https://opencollective.com/Carbon/sponsor/8/website" target="_blank"><img src="https://opencollective.com/Carbon/sponsor/8/avatar.svg"></a>
139
 
140
[[Become a sponsor](https://opencollective.com/Carbon#sponsor)]
141
 
142
### Backers
143
 
144
Thank you to all our backers! 🙏
145
 
146
<a href="https://opencollective.com/Carbon#backers" target="_blank"><img src="https://opencollective.com/Carbon/backers.svg?width=890"></a>
147
 
148
[[Become a backer](https://opencollective.com/Carbon#backer)]
149
 
150
## Carbon for enterprise
151
 
152
Available as part of the Tidelift Subscription.
153
 
154
The maintainers of ``Carbon`` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)