百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

business

> 编程语言
开源

: 日期: 按营业时间计算的时间

360 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

: 日期: 按营业时间计算的时间

Business Build status Version PHP Version

DateTime calculations in business hours

Installation

bash
$ composer require florianv/business

Usage

First you need to configure your business schedule:

…

Methods

within() - Tells if a date is within business hours
php
$bool = $business->within(new \DateTime('2015-05-11 10:00'));
timeline() - Returns a timeline of business dates
php
$start = new \DateTime('2015-05-11 10:00');
$end = new \DateTime('2015-05-14 10:00');
$interval = new \DateInterval('P1D');

$dates = $business->timeline($start, $end, $interval);
closest() - Returns the closest business date from a given date
php
// After that date (including it)
$nextDate = $business->closest(new \DateTime('2015-05-11 10:00'));

// Before that date (including it)
$lastDate = $business->closest(new \DateTime('2015-05-11 10:00'), Business::CLOSEST_LAST);

Serialization

PHP serialization

The Business class can be serialized so it can be stored for later reuse:

php
$serialized = serialize($business);
$business = unserialize($serialized);

If you use SpecialDay instances, you need to install the jeremeamia/superclosure library providing closure serialization:

bash
$ composer require jeremeamia/superclosure

JSON serialization

All classes can be encoded to JSON

php
$json = json_encode($business);

The SpecialDay instances require a context in order extract the data from the callable. This is automatically set to new \DateTime('now') for json_encode() call only.

License

MIT

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPbusiness-hoursdateopening-hoursphp

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言