arokettu/date
最新稳定版本:2.4.0
Composer 安装命令:
composer require arokettu/date
包简介
Date class for PHP (without time)
README 文档
README
A class for php to work with pure dates (without time).
- Works with the proleptic Gregorian calendar by default
- Uses Julian day internally
- Does not depend on the calendar extension
- Correctly supports full integer range for the dates (-5884323-05-15 to 5874898-06-03 on a 32-bit system, even more on 64-bit)
- Additional calendars:
Installation
composer require arokettu/date
Usage
The library:
<?php use Arokettu\Date\Calendar; use Arokettu\Date\Date; use Arokettu\Date\JulianCalendar; use Arokettu\Date\Month; // creation $date = Date::today(); // example: 2024-02-27 // or $date = Calendar::create(2024, Month::February, 27); // or $date = Calendar::fromDateTime(new DateTime('Feb 27, 2024')); // truncates time // or $date = Calendar::parse('2024-02-27'); // Y-m-d is expected, years can be negative // or $date = Calendar::parseDateTimeString('Feb 27, 2024'); // alternative calendars $date = JulianCalendar::parse('2024-02-14'); // getters $date->getDay(); // 27 $date->getMonth(); // Month::February $date->getMonthNumber(); // 2 $date->getYear(); // 2024 $date->getWeekDay(); // WeekDay::Tuesday $date->getJulianDay(); // 2460368 $date->toDateTime(); // DateTimeImmutable('2024-02-27') // midnight in a default timezone $date->toString(); // "2024-02-27" // alternative calendar getters $date->julian()->getDay(); // 14 $date->julian()->toString(); // "2024-02-14"
Documentation
Read full documentation here: https://sandfox.dev/php/date.html
Also on Read the Docs: https://php-date.readthedocs.io/
Support
Please file issues on our main repo at GitLab: https://gitlab.com/sandfox/php-date/-/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.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-26