Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
zh_TW.php | 2017-07-31 | 755 Bytes | |
vi.php | 2017-07-31 | 792 Bytes | |
zh.php | 2017-07-31 | 746 Bytes | |
uz.php | 2017-07-31 | 1.1 kB | |
ur.php | 2017-07-31 | 610 Bytes | |
tr.php | 2017-07-31 | 768 Bytes | |
uk.php | 2017-07-31 | 1.4 kB | |
th.php | 2017-07-31 | 1.2 kB | |
sv.php | 2017-07-31 | 897 Bytes | |
sr_Latn_ME.php | 2017-07-31 | 1.6 kB | |
sr_ME.php | 2017-07-31 | 1.6 kB | |
sr_Cyrl_ME.php | 2017-07-31 | 1.8 kB | |
sr.php | 2017-07-31 | 1.2 kB | |
sl.php | 2017-07-31 | 1.8 kB | |
sq.php | 2017-07-31 | 894 Bytes | |
ru.php | 2017-07-31 | 1.4 kB | |
sk.php | 2017-07-31 | 1.1 kB | |
ro.php | 2017-07-31 | 1.1 kB | |
pt_BR.php | 2017-07-31 | 890 Bytes | |
pt.php | 2017-07-31 | 893 Bytes | |
pl.php | 2017-07-31 | 1.1 kB | |
nl.php | 2017-07-31 | 866 Bytes | |
no.php | 2017-07-31 | 888 Bytes | |
ms.php | 2017-07-31 | 786 Bytes | |
mk.php | 2017-07-31 | 738 Bytes | |
lt.php | 2017-07-31 | 1.7 kB | |
lv.php | 2017-07-31 | 2.1 kB | |
ko.php | 2017-07-31 | 758 Bytes | |
km.php | 2017-07-31 | 948 Bytes | |
ja.php | 2017-07-31 | 764 Bytes | |
ka.php | 2017-07-31 | 950 Bytes | |
it.php | 2017-07-31 | 904 Bytes | |
id.php | 2017-07-31 | 788 Bytes | |
hy.php | 2017-07-31 | 838 Bytes | |
hu.php | 2017-07-31 | 1.6 kB | |
he.php | 2017-07-31 | 1.2 kB | |
hr.php | 2017-07-31 | 1.2 kB | |
fr.php | 2017-07-31 | 887 Bytes | |
gl.php | 2017-07-31 | 649 Bytes | |
fo.php | 2017-07-31 | 912 Bytes | |
fi.php | 2017-07-31 | 968 Bytes | |
eu.php | 2017-07-31 | 890 Bytes | |
fa.php | 2017-07-31 | 826 Bytes | |
es.php | 2017-07-31 | 906 Bytes | |
et.php | 2017-07-31 | 1.2 kB | |
eo.php | 2017-07-31 | 914 Bytes | |
en.php | 2017-07-31 | 827 Bytes | |
el.php | 2017-07-31 | 1.1 kB | |
de.php | 2017-07-31 | 1.2 kB | |
cs.php | 2017-07-31 | 1.1 kB | |
da.php | 2017-07-31 | 884 Bytes | |
ca.php | 2017-07-31 | 886 Bytes | |
bn.php | 2017-07-31 | 1.2 kB | |
az.php | 2017-07-31 | 776 Bytes | |
bg.php | 2017-07-31 | 1.1 kB | |
ar.php | 2017-07-31 | 1.8 kB | |
af.php | 2017-07-31 | 879 Bytes | |
Totals: 57 Items | 60.6 kB | 0 |
Carbon
A simple PHP API extension for DateTime. http://carbon.nesbot.com
use Carbon\Carbon;
printf("Right now is %s", Carbon::now()->toDateTimeString());
printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); //implicit __toString()
$tomorrow = Carbon::now()->addDay();
$lastWeek = Carbon::now()->subWeek();
$nextSummerOlympics = Carbon::createFromDate(2012)->addYears(4);
$officialDate = Carbon::now()->toRfc2822String();
$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;
$noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London');
$worldWillEnd = Carbon::createFromDate(2012, 12, 21, 'GMT');
// Don't really want to die so mock now
Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));
// comparisons are always done in UTC
if (Carbon::now()->gte($worldWillEnd)) {
die();
}
// Phew! Return to normal behaviour
Carbon::setTestNow();
if (Carbon::now()->isWeekend()) {
echo 'Party!';
}
echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago'
// ... but also does 'from now', 'after' and 'before'
// rolling up to seconds, minutes, hours, days, months, years
$daysSinceEpoch = Carbon::createFromTimestamp(0)->diffInDays();
Installation
With Composer
$ composer require nesbot/carbon
{
"require": {
"nesbot/carbon": "~1.21"
}
}
<?php
require 'vendor/autoload.php';
use Carbon\Carbon;
printf("Now: %s", Carbon::now());
Without Composer
Why are you not using composer? Download Carbon.php from the repo and save the file into your project path somewhere.
<?php
require 'path/to/Carbon.php';
use Carbon\Carbon;
printf("Now: %s", Carbon::now());