yashar-rashedi/jalali-date
Composer 安装命令:
composer require yashar-rashedi/jalali-date
包简介
Jalali calendar conversion to gregorian and vise versa.
关键字:
README 文档
README
Convert Gregorian calendar date to Jalali
$date = new Jalali();
echo $date->setGregorianDate(new \DateTime())->getJalali()->format('Y/m/d');
As you may have noticed, you can use PHP's standard date format characters to format your Jalali date. Isn't that cool?
Convert Jalali calendar date to Gregorian
$date = new Jalali(1392, 6, 6);
echo $date->getGregorian()->format('Y/m/d');
Formatting the converted date
Let's say you want to output the Jalali converted date to something like "پنج شنبه، ۸ شهریور ۱۳۹۲" You can achieve this by
$date = new Jalali();
echo $date->setGregorianDate(new \DateTime())->getJalali()->format('w, d F Y');
This looks pretty much like the above code. All I have done is that I have provided a different format string w, d F Y
Adding units of date/time to the Jalali calendar date
To add a number of years/months/days/hours/minutes/seconds to the converted Jalali date you can use the add() method.
This method accepts two arguments. The first one is the number of units to add to the date and the second one is the date/time designator character.
Let's say you want to add 7 days to the current date.
$date = new Jalali(1392, 6, 6);
echo $date->add(7, 'D')->format('Y/m/d');
You could also do it like this:
$date = new Jalali(1392, 6, 6);
echo $date->add(1, 'W')->format('Y/m/d');
Again if you've noticed, PHP's standard DateInterval characters are used to add units of date/time to the Jalali date.
You can also use negative values for the unit being added to the Jalali date to subtract the amount of date/time from the Jalali date if you need to navigate backward in time.
Convert TIMESTAMP to a Jalali calendar date
$date = new Jalali();
echo $date->setTimestamp(time())->getJalali()->format('Y/m/d');
It was that simple. All you need to do to convert a timestamp.
yashar-rashedi/jalali-date 适用场景与选型建议
yashar-rashedi/jalali-date 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 841 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「jalali calendar」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yashar-rashedi/jalali-date 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yashar-rashedi/jalali-date 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yashar-rashedi/jalali-date 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A modern PHP library for generating iCalendar v2.0 events
A powerful event calendar Tool for Laravel's Nova 5.
Convert eloquent date attributes to jalali (Persian) dates on the fly. (supports model propery access, toJson, toString and toArray).
Check for holidays - localeaware
This TYPO3 distribution provides a sample website using bootstrap and the extensions pizpalue and container_elements. The distribution tailors Swiss market featuring German as default language and additional translations to French, English and Finnish.
Laravel Jalali datetime component known as ZAMAN
统计信息
- 总下载量: 841
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2025-01-29