Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

nesbot/carbon 3.0.0

An API extension for DateTime that supports 281 different languages.
Package summary
Share
0
issues
0
licenses
Package created
11 Sep 2012
Version published
31 Jan 2024
Maintainers
2
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does nesbot/carbon do?

Nesbot/Carbon is a PHP extension for DateTime that supports over 281 languages. This internationalized package facilitates quick and easy manipulation of dates and times, supporting a wealth of operations such as parsing, formatting, comparing and differently adjusting dates. The package is highly versatile, offering in-built localization options that make it a fantastic tool for developers working on international projects or global platforms.

How do you use nesbot/carbon?

Using Nesbot/Carbon is straightforward and easy, even for beginners in PHP. Installation can be done using Composer. Here's an example of a command to install it:

$ composer require nesbot/carbon

You can then include the Carbon class in your PHP file and use it as shown;

<?php
require 'vendor/autoload.php';
use Carbon\Carbon;
printf("Now: %s", Carbon::now());

With Carbon, you can perform various operations with dates and times like so:

use Carbon\Carbon;
printf("Right now is %s", Carbon::now()->toDateTimeString()); // Prints current date and time
$lastWeek = Carbon::now()->subWeek(); // Gets the date for the previous week
$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age; // Calculates ages from birthdate

For projects not using Composer, Carbon can be manually installed by downloading the latest release from GitHub, extracting it within the project, and then requiring the autoload.php file.

Where are the nesbot/carbon docs?

The documentation for the Nesbot/Carbon package provides a comprehensive guide for using the extension. It covers everything from installation, usage, in-depth explanations of methods, attributes and the API. The documentation can be accessed from here.