- Php
- Features
- Autoload
- Class Reflection
- Magic Methods
- Exceptions
- Late Static Binding
- Type Hinting
- SPL
- PHPUNIT
- PHAR
- Composer
- Guzzle
- Carbon ♣
- Faker
- Math
- Requests
- Design Patterns
- Singleton Pattern
- Observer Pattern
- Strategy Pattern
- Registry
- Symfony
- Routes
- Annotations
- Flex
- Controllers
- Doctrine
- Templating
- Versions
- Php7.4
- Php8.0
- Security
- Filter Input
- Remote Code Injection
- Sql Injection
- Session Fixation
- File Uploads
- Cross Site Scripting
- Spoofed Forms
- CSRF
- Session Hijacking
- Modern Php
- Composer
- Slim Framework
- Autoloader
- Package
- Releases
- Generators
- Dependency Injection
- Middleware
- Create Framework
- App
- Http Foundation
- Front Controller
- Routing
- Render Controller
- Resolver
- SoC
- Frameworks
- Symfony V5
- Laravel V8
- Laminas V3
- Codeigniter V4
Carbon
An international PHP extension for DateTime.
/**
* The Carbon class is inherited from the PHP DateTime class.
*
* composer require nesbot/carbon
*/
require __DIR__ . '/vendor/autoload.php';
use Carbon\Carbon;
/**
* next
*/
$now = Carbon::now();
$dt = Carbon::parse($now);
echo $dt->hour . "\n";
$date = $now->add(1, 'day');
echo $date->isoFormat('dddd D') . "\n";
// Tuesday 29
$date = $now->add(1, 'month');
echo $date->isoFormat('YYYY-MM-DD') . "\n";
// 2022-04-29
/**
* timezone
*/
$now = Carbon::now();
$dt = Carbon::parse($now);
echo $dt->timezone . "\n";
// Europe/Helsinki
echo $dt->hour . "\n";
// 16
$nowLondon = Carbon::now('Europe/London');
$dt = Carbon::parse($nowLondon);
echo $dt->hour . "\n";
// 14
DateTime
Date and time from the server where your PHP scripts are running.
// Add time to get a future date
$date = new DateTime();
$format = "Y-m-d";
echo $date->format($format) . "\n";
# 2021-12-20
$date->modify("+12 days");
echo $date->format($format) . "\n";
# 2021-01-01
$date->modify("+31 days");
echo $date->format($format) . "\n";
# 2021-02-01
$date->modify("+31 days");
echo $date->format($format) . "\n";
# 2021-03-04
Last update: 61 days ago