wallacemaxters/timespan
最新稳定版本:1.0.2
Composer 安装命令:
composer require wallacemaxters/timespan
包简介
A timespan library
README 文档
README
This is a library to work only with time durations in PHP.
Instalation
composer require wallacemaxters/timespan
How to work
With it you can work with the time very simply:
use WallaceMaxters\Timespan\Timespan; $time = new Timespan(0, 0, 10); echo $time->format(); // '00:00:10' $time->addSeconds(30); echo $time->format(); // '00:00:40' $time->addSeconds(-50); echo $time->format(); // '-00:00:10' $time->addMinutes(2); echo $time->format('%i minutes %s seconds'); // '1 minutes 50 seconds'
An example of time duration:
$time = Timespan::createFromFormat( Timespan::DEFAULT_FORMAT, '26:00:00' ); echo $time->format(); // '26:00:00'
For create time duration from DateTime Diff, you can use Timespan::createFromDateDiff.
$timespan = Timespan::createFromDateDiff( new DateTime('2021-01-01 23:00:00'), new DateTime('2021-01-03 02:00:00') ); echo $timespan->format(); // '27:00:00'
Available time format characters
| Character | Description |
|---|---|
| %h | The hour value. |
| %i | The minute value. From `0`to `59`. |
| %I | The total minutes value. |
| %s | The second value. From `0`to `59`. |
统计信息
- 总下载量: 1.35k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-13