arokettu/datetime-rounding
最新稳定版本:1.0.0
Composer 安装命令:
composer require arokettu/datetime-rounding
包简介
DateTime rounding helper
关键字:
README 文档
README
A tool to truncate a DateTime instance to a specific time unit.
Installation
composer require arokettu/datetime-rounding
Example
<?php use Arokettu\DateTime\DateTimeTruncate; use Carbon\CarbonImmutable; // to hours $dateTime = new DateTimeImmutable('2012-03-04T05:06:07.890123Z'); echo DateTimeTruncate::toHours($dateTime)->format('c'); // 2012-03-04T05:00:00+00:00 // truncating to dates uses the DT timezone $dateTime = new DateTimeImmutable('2012-03-04T05:06:07.890123 Europe/Stockholm'); echo DateTimeTruncate::toMonths($dateTime)->format('c'); // 2012-03-01T00:00:00+01:00 // using mutable will change the object $dateTime = new DateTime('2012-03-04T05:06:07.890123Z'); DateTimeTruncate::toMinutes($dateTime); echo $dateTime->format('c'); // 2012-03-04T05:06:00+00:00 // the tool tries to preserve the extended objects as well $dateTime = new CarbonImmutable('2012-03-04T05:06:07.890123Z'); echo get_class(DateTimeTruncate::toMonths($dateTime)); // Carbon\CarbonImmutable
Documentation
Read full documentation here: https://sandfox.dev/php/datetime-rounding.html
Support
Please file issues on our main repo at GitLab: https://gitlab.com/sandfox/datetime-rounding/-/issues
Feel free to ask any questions in our room on Gitter: https://gitter.im/arokettu/community
License
The library is available as open source under the terms of the MIT License.
统计信息
- 总下载量: 1.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-15