1. Go to this page and download the library: Download bangladatetime/laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bangladatetime / laravel example snippets
use App\Models\User;
// Retrieve a user and format the created_at attribute in Bangla format
$user = User::find(1);
echo $user->created_at->formatBangla('l jS F Y h:i:s');
// Format the created_at attribute in Bangla calendar format
echo $user->created_at->toBangla('l jS F Y h:i:s');
use Illuminate\Support\Carbon;
// Get current date and time in Bangla format
echo Carbon::now()->formatBangla('l jS F Y h:i:s');
// Get current date and time in Bangla calendar format
echo Carbon::now()->toBangla('l jS F Y h:i:s');
use Illuminate\Support\Carbon;
// Set a custom date ('2023-04-13') in Bangla format
echo Carbon::create('2023-04-13')->formatBangla('l jS F Y h:i:s');
// Set a custom date ('2023-04-13') in Bangla calendar format
echo Carbon::create('2023-04-13')->toBangla('l jS F Y h:i:s');
use Illuminate\Support\Carbon;
// Set current time with a specific timezone ('Asia/Dhaka') in Bangla format
echo Carbon::now('Asia/Dhaka')->formatBangla('l jS F Y h:i:s');
// Set current time with a specific timezone ('Asia/Dhaka') in Bangla calendar format
echo Carbon::now('Asia/Dhaka')->toBangla('l jS F Y h:i:s');
use Illuminate\Support\Carbon;
// Get current date and time in Bangla format with a custom format and timezone
echo Carbon::now()->formatBangla('d/m/Y H:i:s', 'Asia/Dhaka');
// Get current date and time in Bangla calendar format with a custom format and timezone
echo Carbon::now()->toBangla('d/m/Y H:i:s', 'Asia/Dhaka');