Download the PHP package rohanadhikari/nepali-date without Composer
On this page you can find all versions of the php package rohanadhikari/nepali-date. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rohanadhikari/nepali-date
More information about rohanadhikari/nepali-date
Files in rohanadhikari/nepali-date
Package nepali-date
Short Description A PHP package for handling Nepali Date and Time (Bikram Sambat - BS), with AD/BS conversion, formatting, and Laravel support.
License MIT
Informations about the package nepali-date
NepaliDate — Bikram Sambat (BS) Date & Time for PHP
NepaliDate is a dependency-free PHP library for working with the Nepali calendar (Bikram Sambat / BS) — the calendar of Nepal. It converts between AD (Gregorian) and BS, formats, parses, compares, and manipulates Nepali dates with a fluent, Carbon-inspired API, and ships first-class Laravel support (Eloquent casts, validation rules, and Blade directives).
Whether you're building a Nepali government portal, a Nepal-based e-commerce app, a school/attendance system, or just need accurate AD ⇄ BS date conversion in PHP, NepaliDate gives you a complete, tested toolkit instead of hand-rolled conversion math.
✨ Features
- 🕒 Full Nepali (BS) date and time support — not just year/month/day conversion
- 🗓 Simple, accurate conversion between AD and BS
- 🔁 Both mutable (
NepaliDate) and immutable (NepaliDateImmutable) variants - ➕ Add, subtract, and snap dates by year, month, day, hour, minute, or second
- 🌐 Built-in Nepali (
np) and English (en) locales, with full customization support - 🔢 Format dates with
date()-style tokens, or use predefined format constants - 🔍 Rich comparison API —
isToday(),isWeekend(),between(), and more - 🧩 Laravel-ready: Eloquent casts, form validation rules, and Blade directives out of the box
- 🔤 Standalone
NepaliNumbersutility for digit, currency, and word conversion
📦 Installation
Install via Composer:
No other setup is required for plain PHP. In Laravel, the service provider is auto-discovered — see Laravel Integration.
🚀 Quick Start
[!NOTE] Predefined format constants are listed in Constants.
Using in plain PHP (no framework)
Make sure the path to vendor/autoload.php is correct relative to your script — Composer is the recommended way to load the package.
📖 Documentation
The core README covers the essentials; everything else lives in docs/, organized by topic (Carbon-style) so you only read what you need:
| Guide | Covers |
|---|---|
| Initialization | now(), fromAd(), fromNotation(), fromTimestamp(), direct construction |
| Formatting | Format tokens, examples, locale-aware output |
| Parsing | parse(), createFromFormat(), custom parse patterns |
| Arithmetic & Shifting | Add/subtract units, month overflow control, diff, timezone/week shifting |
| Getters | Year, time, day, month, timezone, and locale-based accessors |
| Setters | Basic, unit-based, and combined setters |
| Boundaries | startOf()/endOf() for day, week, month, quarter, year, decade... |
| Comparison | eq(), between(), isToday(), isWeekend(), and other state checks |
| Constants | Weekday, month, locale, and format constants |
| Locale Customization | Customizing month/weekday names per locale |
| Macros | Adding custom methods at runtime |
| Nepali Numbers | Digit, currency, and word conversion utilities |
| Calendar | Low-level BS/AD calendar math and lookup tables |
| Exceptions | What can be thrown, and how to guard against it |
| Laravel Integration | Eloquent casts, validation rules, Blade directives |
🌐 Locale
Available locales: en and np.
[!NOTE] Set a global default for every new instance with
NepaliDate::defaultLocale(NepaliDate::NEPALI). See Locale Customization to change the underlying month/weekday names.
Laravel Integration
Casts, form validation rules, and Blade directives (@nepaliDate, @nepaliNow, @nepaliWeekend, ...) are all included and auto-registered — see the Laravel Integration Guide for the full reference.
🧪 Testing
🤝 Contributing
Contributions are welcome and will be fully credited. Please read the Contributing Guide before opening an issue or pull request.
🔒 Security
If you discover a security vulnerability, please see SECURITY.md for responsible disclosure instructions instead of using the public issue tracker.
📄 License
The MIT License (MIT). See LICENSE.md for details.