All Projects → GwendolenLynch → Carbon

GwendolenLynch / Carbon

Licence: mit
A simple PHP API extension for DateTime

Projects that are alternatives of or similar to Carbon

Zulu
A drop-in replacement for native Python datetimes that embraces UTC.
Stars: ✭ 52 (-30.67%)
Mutual labels:  time, date, datetime
Iso8601
Ruby parser to work with ISO8601 dateTimes and durations — http://en.wikipedia.org/wiki/ISO_8601
Stars: ✭ 70 (-6.67%)
Mutual labels:  time, date, datetime
dayjs
Extended fork of Day.js - 2KB immutable date library alternative to Moment.js
Stars: ✭ 36 (-52%)
Mutual labels:  time, datetime, date
Period
PHP's time range API
Stars: ✭ 616 (+721.33%)
Mutual labels:  time, date, datetime
When
A natural language date/time parser with pluggable rules
Stars: ✭ 1,113 (+1384%)
Mutual labels:  time, date, datetime
nepali-datetime
Python's core datetime inspired nepali datetime (BS date & NPT) package 🇳🇵
Stars: ✭ 36 (-52%)
Mutual labels:  time, datetime, date
Vue Datetime
Mobile friendly datetime picker for Vue. Supports date and datetime modes, i18n and more.
Stars: ✭ 928 (+1137.33%)
Mutual labels:  time, date, datetime
chronos
One library to rule the time
Stars: ✭ 17 (-77.33%)
Mutual labels:  time, datetime, date
Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (+614.67%)
Mutual labels:  time, date, datetime
Pendulum
Python datetimes made easy
Stars: ✭ 4,639 (+6085.33%)
Mutual labels:  time, date, datetime
vue-timeselector
🕒 Simply customizable powerful time picker for Vue.js
Stars: ✭ 41 (-45.33%)
Mutual labels:  time, datetime, date
Dayjs
⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
Stars: ✭ 37,373 (+49730.67%)
Mutual labels:  time, date, datetime
moment-cache
⏱ Simple utility to cache moment.js results and speed up moment calls.
Stars: ✭ 29 (-61.33%)
Mutual labels:  time, datetime, date
Laydate
layDate(日期与时间组件) 是 layui 独立维护的三大组件之一
Stars: ✭ 1,066 (+1321.33%)
Mutual labels:  time, date, datetime
rescript-date
📆 Date manipulation in ReScript.
Stars: ✭ 101 (+34.67%)
Mutual labels:  time, datetime, date
date-php
这是一个Javascript模仿PHP日期时间格式化函数,使用方法和PHP非常类似,有丰富的模板字符,并在原来的基础上增加了一些模板字符。 This is a date function that implement PHP in Javascript. It is very similar to PHP, has rich template characters, and enhances some template characters on the basis of the original.
Stars: ✭ 24 (-68%)
Mutual labels:  time, datetime, date
dt
Go's missing DateTime package
Stars: ✭ 34 (-54.67%)
Mutual labels:  time, datetime, date
shamsi date
A Flutter and Dart package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) date and times.
Stars: ✭ 59 (-21.33%)
Mutual labels:  time, datetime, date
React Datetime Picker
A datetime picker for your React app.
Stars: ✭ 294 (+292%)
Mutual labels:  time, date, datetime
Carbon
A simple, semantic and developer-friendly golang package for datetime
Stars: ✭ 565 (+653.33%)
Mutual labels:  time, date, datetime

Carbon

Latest Stable Version Total Downloads Build Status StyleCI codecov.io PHP-Eye PHPStan

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(2016)->addYears(4);

$officialDate = Carbon::now()->toRfc2822String();

$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;

$noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London');

$internetWillBlowUpOn = Carbon::create(2038, 01, 19, 3, 14, 7, 'GMT');

// Don't really want this to happen so mock now
Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));

// comparisons are always done in UTC
if (Carbon::now()->gte($internetWillBlowUpOn)) {
    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());

Docs

http://carbon.nesbot.com/docs

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].