adrian-cid/julian-converter
Composer 安装命令:
composer require adrian-cid/julian-converter
包简介
A PHP library for converting dates between the Gregorian calendar and Julian dates, with support for time precision down to seconds. Ideal for date manipulations, calendar conversions, and astronomical calculations.
关键字:
README 文档
README
Julian Date Converter is a simple PHP library for converting dates between the Gregorian calendar and Julian dates, with precision down to seconds. It handles both conversions, taking into account the fractional day for exact time calculations.
Installation
You can install this package using Composer.
composer require adrian-cid/julian-converter
Requirements
- PHP 8.2 or higher.
Usage
1. Convert Gregorian Date to Julian Date
You can convert any DateTime object from the Gregorian calendar to its equivalent Julian Date. The result will be a float representing the Julian Date, including the fractional day for hours, minutes, and seconds.
use AdrianCid\Calendar\JulianConverter; // Create a DateTime object with the desired date and time. $gregorian_date = new \DateTime('2024-10-02 15:30:00'); // Instantiate the converter and convert the Gregorian date to Julian date. $converter = new JulianConverter(); $julian_date = $converter->convertGregorianToJulianDate($gregorian_date); echo "The Julian Date is: " . $julian_date; // Output: The Julian Date is: 2460111.145833
2. Convert Julian Date to Gregorian Date
To convert a Julian Date back to the Gregorian calendar, use the convertJulianToGregorianDate() method. The result will be a DateTime object representing the equivalent Gregorian date and time.
use AdrianCid\Calendar\JulianConverter; // Example Julian date. $julian_date = 2460111.145833; // Convert the Julian date back to a Gregorian DateTime object. $gregorian_date = $converter->convertJulianToGregorianDate($julian_date); echo "The Gregorian Date is: " . $gregorian_date->format('Y-m-d H:i:s'); // Output: The Gregorian Date is: 2024-10-02 15:30:00
Methods
convertGregorianToJulianDate(\DateTime $gregorian_date): float
Converts a DateTime object (Gregorian date) into a Julian Date as a float. The fractional part of the Julian Date reflects the time of day.
-
Parameters:
\DateTime $gregorian_date: The date to be converted (Gregorian).
-
Returns:
float: The Julian Date with the fractional day included.
convertJulianToGregorianDate(float $julian_date): \DateTime
Converts a Julian Date to a DateTime object (Gregorian date).
-
Parameters:
float $julian_date: The Julian date to be converted.
-
Returns:
\DateTime: The equivalent Gregorian date and time.
License
This package is licensed under the GPL-3.0 License. See the LICENSE file for more details.
adrian-cid/julian-converter 适用场景与选型建议
adrian-cid/julian-converter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 172 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「calendar」 「datetime」 「gregorian」 「astronomy」 「julian」 「Time conversion」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adrian-cid/julian-converter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adrian-cid/julian-converter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adrian-cid/julian-converter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Tools to convert between .NET and PHP date formats
Time provider, providing consistent current date, time, datetime and timezone across the request.
A modern PHP library for generating iCalendar v2.0 events
Adds the EDTF data type to Wikibase
Nepali (Bikram Sambat) calendar utilities and BS ↔ AD date conversion for PHP.
Datetime helpers for timezone handling
统计信息
- 总下载量: 172
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2024-10-03