Skip to content

matheus-rosa/php-calendar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-calendar

A small lightweight library to handle with calendar operations.

This library is an API to extend native PHP DateTime features.

Requirements

PHP >= 5.*

Usage

use Calendar\App\Calendar;

// Returns a DateTime instance.
var_dump(Calendar::today());
var_dump(Calendar::tomorrow());
var_dump(Calendar::yesterday());

// Get the next day of week based in current date
var_dump(Calendar::now()->nextMonday());
var_dump(Calendar::now()->nextWednesday());

// Returns an array of DateTime objects
$onlyFridays = Calendar::interval('2020-01-01', '2020-03-31')
                        ->onlyFridays();

$onlyTuesdays = Calendar::interval('2020-01-01', '2020-03-31')
                        ->onlyTuesdays();

var_dump($onlyFridays, $onlyTuesdays);

// You can also compute the next/before days from now
Calendar::now()->nextDays(15);
Calendar::now()->beforeDays(15);

// Or specifying a base date
Calendar::fromDate('2020-04-25')->nextDays(15);
Calendar::fromDate('2020-04-25')->beforeDays(15);

// Or even set a specific timezone before handle its operations
Calendar::setTimezone('America/Sao_Paulo');

About

A library to easily handle date operations

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages