Download the PHP package pdatepicker/persian-datepicker without Composer
On this page you can find all versions of the php package pdatepicker/persian-datepicker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pdatepicker/persian-datepicker
More information about pdatepicker/persian-datepicker
Files in pdatepicker/persian-datepicker
Package persian-datepicker
Short Description A modern Persian (Jalali) datepicker package for Laravel applications with customizable themes and extensive options
License MIT
Informations about the package persian-datepicker
Persian Datepicker for Laravel
A modern, elegant, and feature-rich Persian (Jalali) datepicker package for Laravel applications, with extensive customization options.
Features
- 📅 Persian (Jalali) calendar support with weekend highlighting
- 🎨 Multiple themes (default, dark, blue) with complete customization
- 🔄 Seamless conversion between Jalali and Gregorian dates
- ⚙️ Highly configurable with numerous options
- 🕒 Advanced time picker with 12/24 hour format support
- 📆 Multiple calendar types (date, month, year) for different selection needs
- 📱 Fully responsive and mobile-friendly design
- 🔤 Multi-language support (Persian and English)
- 🖌️ RTL and LTR support for multi-directional applications
- 🚀 Effortless integration with Laravel Blade directives
- 🎯 Support for model binding in Laravel forms
Laravel Compatibility
Laravel Version | Package Version |
---|---|
10.x | 1.x |
9.x | 1.x |
8.x | 1.x |
Requirements
- PHP 7.3 or higher
- Laravel 8.0 or higher
Installation
Step 1: Install via Composer
Step 2: Publish Assets and Configuration
For Laravel apps, publish the necessary assets and configuration file:
This will:
- Copy the JavaScript and CSS assets to your public directory
- Create the
config/pdatepicker.php
configuration file - (Optional) Copy usage examples to your public directory
Step 3: Add to Your Layout
Add the CSS and JavaScript files to your layout:
Laravel Integration
Using in Blade Templates
You can use the provided Blade directive to easily add datepickers to your forms:
With Laravel Collective Forms
If you're using Laravel Collective's form package:
Validation
For form validation, use the jalali_date
validation rule:
Or use the rule in your form request:
Working with Laravel Models
Accessors and Mutators
Use accessors and mutators to automatically convert between Jalali and Gregorian dates:
Examples
The package includes several complete examples to demonstrate different usage scenarios:
- Basic Examples: Shows simple datepicker initialization with various options
- Advanced Examples: Demonstrates integration with forms, date ranges, and validation
- Calendar Types: Showcases year, month, and date picker implementations
- Custom Styling: Examples of visual customization options
After publishing the assets, you can find these examples at:
Or you can view them directly in the source code at:
Configuration Options
You can configure default behavior by editing the config/pdatepicker.php
file:
Available Options
Option | Type | Default | Description |
---|---|---|---|
format |
string | 'YYYY/MM/DD' | Date format |
theme |
string | 'default' | Datepicker theme ('default', 'dark', 'blue') |
rtl |
boolean | true | Enable RTL mode |
language |
string | 'fa' | Language ('fa', 'en') |
autoClose |
boolean | true | Close datepicker after selecting a date |
timePicker |
boolean | false | Show time picker |
timeFormat |
string | 'HH:mm:ss' | Format for time display |
type |
string | 'date' | Calendar type ('date', 'month', 'year') |
viewMode |
string | 'day' | Initial view mode ('day', 'month', 'year') |
minDate |
string | null | Minimum selectable date |
maxDate |
string | null | Maximum selectable date |
initialValue |
string | null | Initial date value |
position |
string | 'bottom' | Datepicker position ('bottom', 'top') |
altField |
string | null | Alternative field selector |
altFormat |
string | null | Alternative field format |
onSelect |
function | null | Callback when a date is selected |
onShow |
function | null | Callback when datepicker is shown |
onHide |
function | null | Callback when datepicker is hidden |
customStyles |
object | {} | Custom CSS styles for datepicker elements |
Methods
PHP Methods (Available via Facade)
Method | Description |
---|---|
toJalali($date, $format = 'Y/m/d') |
Convert Gregorian date to Jalali |
toGregorian($date, $format = 'Y-m-d') |
Convert Jalali date to Gregorian |
now($format = 'Y/m/d') |
Get current Jalali date |
render($name, $value = null, array $options = []) |
Render datepicker HTML |
JavaScript Methods
Method | Description |
---|---|
show() |
Show the datepicker |
hide() |
Hide the datepicker |
setDate(date) |
Set the datepicker date programmatically |
updateStyles(styles) |
Update datepicker styles dynamically |
refreshView() |
Refresh the calendar view |
Additional Resources
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you discover any issues or have questions, please open an issue on GitHub.
Credits
This package was created by [Your Name/Organization] and is inspired by modern datepicker solutions.
License
The MIT License (MIT). Please see License File for more information.
Using Different Calendar Types
The package supports different calendar types to suit various input needs:
Date Picker (Default)
Month Picker
Year Picker
JavaScript Implementation for Calendar Types
Theming Options
The datepicker comes with several built-in themes:
Default Theme
Dark Theme
Blue Theme
Custom Theme with Inline Styles
Creating a Custom Theme with CSS
You can also create a custom theme using CSS:
-
Create a CSS file with your theme styles:
-
Include the CSS file in your layout:
- Use the custom theme:
Using the Facade
The package provides a convenient facade for working with dates in your controllers and models:
Events and Callbacks
The datepicker supports various events and callbacks for advanced integrations:
JavaScript Event Handling
Form Integration with Events
Real-time Style Updates
You can dynamically change the datepicker appearance:
Advanced Usage Scenarios
Date Range Selection
Create a date range picker by linking two datepickers: