Download the PHP package chen-ht12306/chronos without Composer
On this page you can find all versions of the php package chen-ht12306/chronos. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package chronos
Chronos
一个优雅的 PHP 日期时间处理库,类似 Carbon,提供链式调用和丰富的时间操作方法。
特性
- ✨ 链式调用 API
- 🕐 完整的时区支持
- 📅 丰富的日期时间操作方法
- 🔄 日期比较和差异计算
- 🌐 中文本地化支持
- 📦 Laravel 原生集成
- 🧪 测试辅助功能
安装
Laravel 集成
注册服务提供者
在 config/app.php 中添加:
发布配置文件
快速开始
基本使用
日期操作
日期比较
日期差异
格式化输出
中文支持
时区处理
获取日期组件
测试支持
转换为其他类型
API 文档
静态工厂方法
| 方法 | 描述 |
|---|---|
now($tz) |
获取当前时间 |
today($tz) |
获取今天的日期 |
tomorrow($tz) |
获取明天的日期 |
yesterday($tz) |
获取昨天的日期 |
create($y, $m, $d, $h, $i, $s, $tz) |
创建指定日期 |
parse($time, $tz) |
解析日期字符串 |
createFromFormat($format, $time, $tz) |
从格式创建 |
createFromTimestamp($timestamp, $tz) |
从时间戳创建 |
实例方法
修改方法
| 方法 | 描述 |
|---|---|
addDays($n) |
添加 n 天 |
subDays($n) |
减去 n 天 |
addMonths($n) |
添加 n 月 |
subMonths($n) |
减去 n 月 |
addYears($n) |
添加 n 年 |
subYears($n) |
减去 n 年 |
addHours($n) |
添加 n 小时 |
subHours($n) |
减去 n 小时 |
startOfDay() |
一天开始 |
endOfDay() |
一天结束 |
startOfMonth() |
月初 |
endOfMonth() |
月末 |
startOfYear() |
年初 |
endOfYear() |
年末 |
setTimezone($tz) |
设置时区 |
比较方法
| 方法 | 描述 |
|---|---|
equalTo($date) |
是否等于 |
greaterThan($date) |
是否大于 |
lessThan($date) |
是否小于 |
isToday() |
是否今天 |
isTomorrow() |
是否明天 |
isYesterday() |
是否昨天 |
isWeekend() |
是否周末 |
isLeapYear() |
是否闰年 |
diffInDays($date) |
天数差异 |
格式化方法
| 方法 | 描述 |
|---|---|
format($format) |
自定义格式 |
toDateString() |
Y-m-d |
toTimeString() |
H:i:s |
toDateTimeString() |
Y-m-d H:i:s |
toCnDateString() |
中文日期 |
toAtomString() |
ATOM 格式 |
配置
发布配置文件后,可以在 config/chronos.php 中修改:
贡献
欢迎提交 Issue 和 Pull Request!
许可证
MIT License
All versions of chronos with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1
illuminate/contracts Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
illuminate/contracts Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
The package chen-ht12306/chronos contains the following files
Loading the files please wait ...