Download the PHP package bangladatetime/laravel without Composer
On this page you can find all versions of the php package bangladatetime/laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bangladatetime/laravel
More information about bangladatetime/laravel
Files in bangladatetime/laravel
Package laravel
Short Description A Laravel package to format DateTime to Bangla and support Bangla calendar.
License MIT
Informations about the package laravel
BanglaDateTime
BanglaDateTime is a Laravel package that allows you to easily format and convert DateTime to the Bangla calendar and Bangla number formats. It supports both current time and custom dates, as well as timezones.
Features
- Convert DateTime to Bangla format.
- Convert to the Bangla calendar (Bengali Era).
- Supports custom dates and timezones.
- Easy to use with a fluent API.
- Helper functions for easy access to common operations.
Installation
You can install the package via Composer:
Laravel Integration
To integrate BanglaDateTime with Laravel, follow these steps:
-
Publish the Configuration File:
Run the following command to publish the package configuration file:
This will create a configuration file at
config/bangladatetime.php
. -
Configuration:
Edit the
config/bangladatetime.php
file to set your desired date formats and timezone. -
Usage:
The package integrates with Laravel's
Carbon
class, allowing you to use custom methods to format dates in Bangla format and Bangla calendar directly.
Using with Eloquent Models
If you have a model with a datetime
cast, you can easily format the datetime attributes using the BanglaDateTime methods. For example:
Output:
Basic Example
Output:
Setting a Custom Date
Output:
Working with Timezones
Output:
Custom Format and Timezone
You can specify a custom format and timezone when calling formatBangla
and toBangla
methods:
Output:
API
BanglaDateTime::create($time = 'now', $timezone = 'UTC')
Creates a new BanglaDateTime
instance.
$time
: The date and time to use (optional, defaults to'now'
).$timezone
: The timezone to use (optional, defaults to'UTC'
).
format($format)
Formats the date and time using a specified format, with the output in the Bangla locale.
$format
: The format string (same as PHP'sDateTime::format
).
toBangla($format)
Converts and formats the date and time into the Bangla calendar and Bangla numbers.
$format
: The format string (same as PHP'sDateTime::format
).
Helper Functions
BanglaDateTime provides the following global helper functions for easy access:
-
bangla_date_time($time = 'now', $timezone = 'UTC')
: Creates a newBanglaDateTime
instance. -
format_bangla_date($format, $time = 'now', $timezone = 'UTC')
: Formats a date/time in Bangla format. convert_to_bangla_calendar($format, $time = 'now', $timezone = 'UTC')
: Converts a date/time to Bangla calendar format.
Contributing
Feel free to contribute by submitting a pull request or opening an issue. Your contributions are highly appreciated!
License
This library is open-sourced software licensed under the MIT license.
All versions of laravel with dependencies
bangladatetime/php Version ^1.0
illuminate/support Version ^8.0||^9.0||^10.0||^11.0