jeeven/nepali-date-converter
Composer 安装命令:
composer require jeeven/nepali-date-converter
包简介
Nepali (BS) ↔ English (AD) Date Converter for Laravel — by Jeeven Lamichhane.
README 文档
README
A lightweight and framework-ready Laravel package for converting and working with Nepali Bikram Sambat (BS) dates and Gregorian (AD) dates using pure PHP.
✨ Features
-
🔁 BS ↔ AD Conversion
- Convert Nepali dates (BS) to Gregorian dates (AD)
- Convert Gregorian dates (AD) to Nepali dates (BS)
-
🧪 Date Validation
- Validate both BS and AD dates
- Auto-normalization of date formats (YYYY/MM/DD, YYYY-MM-DD)
-
📅 Date Formatting
- Format BS dates into Nepali or English
- Supports PHP-like format patterns (
Y,m,d,F,l) - Automatic Nepali digits, weekdays, and months
-
📆 English Date Formatter
- Format AD dates in English or convert to Nepali digits & names (
formattedEnglishDate())
- Format AD dates in English or convert to Nepali digits & names (
-
🔠 Nepali Digit Conversion
- Convert any number/string into Nepali digits (
toNepaliDigits())
- Convert any number/string into Nepali digits (
-
📆 Today's Date Helper
- Get today’s date in AD or BS with custom format (
today())
- Get today’s date in AD or BS with custom format (
-
🔍 Difference Between Two Dates
- Return difference in:
- years
- months
- days
- hours
- minutes
- seconds
- Supports AD and BS dates (
diff())
- Return difference in:
-
📜 Human-Readable Difference
- Human-friendly output (like Laravel’s
diffForHumans) - English or Nepali output (
humanDiff())
- Human-friendly output (like Laravel’s
-
📅 Weekday Extraction
- Get weekday in English or Nepali from BS or AD date
-
🔢 Day-of-Year Calculation
- Compute day number within BS year
-
📘 Total Days in BS Year
- Retrieve total number of days in any BS year
-
🛠 Laravel Compatible
- Works as a Laravel package or standalone in pure PHP
📦 Installation
Install via Composer:
composer require jeeven/nepali-date-converter
Publish configuration (optional):
php artisan vendor:publish --tag=nepali-date-config
🚀 Usage
1. Convert AD → BS
use Jeeven\NepaliDateConverter\Facades\NepaliDate; $bs = NepaliDate::adToBs("2026-07-29"); echo $bs; // "2083-04-14" $bsDate = NepaliDate::adToBs("1999-07-29", true); echo $bsDate->toNepaliFormat(); //२०५६/०४/१३ echo $bsDate->toNepaliHumanFormat(); //२०५६ श्रावण १३, बिहिवार
2. Convert BS → AD
use Jeeven\NepaliDateConverter\Facades\NepaliDate; $ad = NepaliDate::bsToAd("2083-04-14"); echo $ad; // "2026-07-29"
3. Validate AD Date
$isValid = NepaliDate::isValidADDate("2024-02-29"); var_dump($isValid); // false
4. Validate BS Date
$isValid = NepaliDate::isValidBSDate("2080-13-05"); var_dump($isValid); // false
5. Get Full AD Date Info
$info = NepaliDate::getADInfo("2026-07-29"); print_r($info); Output example: [ "adDate" => "2026-07-29", "bsDate" => "2083-04-14", "weekday" => "Thursday", "dayOfYear" => 111, "totalDays" => 365, "diffDays" => -300 ]
6. Get Full BS Date Info
$info = NepaliDate::getBSInfo("2083-04-14"); print_r($info); Output example: [ "adDate" => "2026-07-29", "bsDate" => "2083-04-14", "weekday" => "Thursday", "dayOfYear" => 111, "totalDays" => 365, "diffDays" => -300 ]
7. Get Weekday
NepaliDate::weekdayAD("2026-07-29"); // "Thursday" NepaliDate::weekdayBS("2083-04-14"); // "Thursday" NepaliDate::weekdayAD("2026-07-29", "np"); // "बिहिवार" NepaliDate::weekdayBS("2083-04-14", "np"); // "बिहिवार"
8. Using the Facade
use Jeeven\NepaliDateConverter\Facades\NepaliDate; NepaliDate::adToBs("2024-01-01");
9. NepaliDate Utility Methods
1. formattedNepaliDate($bsDate, $format = 'Y-m-d', $locale = 'en')
This method is used to format a BS (Nepali) date into either Nepali or English formats. It supports custom date formats.
Usage:
echo NepaliDate::formattedEnglishDate("2025-12-03"); // 2025-12-03 echo NepaliDate::formattedEnglishDate("2025-12-03", "d/m/Y"); // 03/12/2025 echo NepaliDate::formattedEnglishDate("2025-12-03", "d F, l"); // 03 December, Wednesday echo NepaliDate::formattedEnglishDate("2025-12-03", "d F, l", "np"); // १७ मंसिर, बुधवार echo NepaliDate::formattedNepaliDate("2082/8/17"); // Default: 2082-08-17 echo NepaliDate::formattedNepaliDate("2082-08-17", "Y/m/d", "np"); // २०८२/०८/१७ echo NepaliDate::formattedNepaliDate("2082-08-17", "d F, l", "np"); // १७ मंसिर, बुधवार echo NepaliDate::formattedNepaliDate("2082/08/17", "d/m/Y", "np"); // १७/०८/२०८२ // Get today's date in English (AD) echo NepaliDate::today(); // Output: 2025-12-08 (example date) // Custom format: English (AD) echo NepaliDate::today("d/m/Y"); // Output: 08/12/2025 // Get today's date in Nepali (BS) echo NepaliDate::today("d/m/Y", "np"); // Output: २२/०८/२०८२ (example BS date) // Get full difference between two AD dates print_r(NepaliDate::diff("2025-12-03", "2025-11-03")); /* Output: [ 'years' => 0, 'months' => 1, 'days' => 30, 'hours' => 720, 'minutes' => 43200, 'seconds' => 2592000 ] */ // Get difference in specific units (days) echo NepaliDate::diff("2025-12-03", "2025-11-03", 'en', 'days'); // Output: 30 // Get full difference between two BS dates print_r(NepaliDate::diff("2082-08-17", "2082-08-10", "np")); /* Output: [ 'years' => 0, 'months' => 0, 'days' => 7, 'hours' => 168, 'minutes' => 10080, 'seconds' => 604800 ] */ // Get difference in specific units (months) echo NepaliDate::diff("2082-08-17", "2082-01-01", "np", "months"); // Output: 7 // Get human-readable difference in English (AD) echo NepaliDate::humanDiff("2025-01-01", "2023-12-01"); // Output: "1 year, 1 month, 0 days" // Get human-readable difference in Nepali (BS) echo NepaliDate::humanDiff("2082-08-17", "2081-01-10", "np", "np"); // Output: "१ वर्ष, ७ महिना, ७ दिन" // Get human-readable difference in English (AD) without years or months echo NepaliDate::humanDiff("2025-01-01", "2025-01-10"); // Output: "9 days" // Get human-readable difference in Nepali (BS) without years or months echo NepaliDate::humanDiff("2082-08-17", "2082-08-10", "np", "np"); // Output: "७ दिन" $number = 1234567; echo NepaliDate::toNepaliDigits($number); // Output: १२३४५६७
⚙️ Configuration (Optional)
File: config/nepali-date.php
return [ "start_year" => 1970, "end_year" => 2090 ];
🧪 Testing
php artisan test
📝 License
This package is open-source and available under the MIT License.
jeeven/nepali-date-converter 适用场景与选型建议
jeeven/nepali-date-converter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.66k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「english」 「nepali」 「date-converter」 「Bikramsambat」 「nepali-date」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jeeven/nepali-date-converter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jeeven/nepali-date-converter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jeeven/nepali-date-converter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DeepL API client wrapper for Laravel
Nepali (Bikram Sambat) calendar utilities and BS ↔ AD date conversion for PHP.
By using this standalone package, you can convert numeric values into words in English based on Bangladeshi numeric counting (lakh-crore).
Package to convert carbon date to nepali date
Convert english to ipa
To convert the unicode digit to another unicode digit.
统计信息
- 总下载量: 1.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-03