ludovicm67/superdate

了解指定日期是否为周末/工作日或节假日(针对法国阿尔萨斯地区)的方法,以及其他一些有趣的功能

v2.0.0 2021-01-17 14:27 UTC

This package is auto-updated.

Last update: 2024-09-19 23:40:48 UTC


README

一些用于处理日期的有用函数

Latest Stable Version Total Downloads Coverage Status License

安装

只需运行以下命令: composer require ludovicm67/superdate 将其添加到您的PHP项目中!

入门

如果您使用composer安装,现在可以创建一个包含以下代码的文件

<?php

// import here the composer autoloader
require('./vendor/autoload.php');

// use the namespace for this library
use ludovicm67\SuperDate\Date;

// your code below...

创建日期对象

有多种初始化对象的方式。

例如

// value: today
$date = new Date();
$date = new Date(null);

// value: specified date
$date = new Date("2019-03-21");

从某一天到另一天的所有日子

获取从当前日期到另一日期的所有日期的数组。

示例

$date = new Date("2019-03-21");
$allDaysTo = $date->allDaysTo("2019-04-03");

// $allDaysTo will be an array containing all 14 days
// between 2019-03-21 and 2019-04-03 included

是工作日还是周末日?

$date->isWeekDay(); // true if between monday and friday, false if saturday or sunday
$date->isWeekEnd(); // false if between monday and friday, true if saturday or sunday

是节假日吗?

基于法国阿尔萨斯的节假日。

用法

$date->isHoliday(); // true if holiday, false if not

想贡献?

请随意分支、提交并提交一个pull-request。

或者直接在这里打开一个问题:https://github.com/ludovicm67/php-superdate/issues