PHP code example of bangladatetime / php

1. Go to this page and download the library: Download bangladatetime/php 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 / php example snippets


use BanglaDateTime\BanglaDateTime;

e with the current date and time, formatted in Bangla locale
$date = BanglaDateTime::create();
echo 'Current time with Bangla format: ' . $date->format('l jS F Y h:i:s');

echo '<br>';

// Create a BanglaDateTime instance with the current date and time, converted to the Bangla calendar
$date = BanglaDateTime::create();
echo 'Current time converted to Bangla: ' . $date->toBangla('l jS F Y h:i:s');

// Create a BanglaDateTime instance with a custom date ('2023-04-13'), formatted in Bangla locale
$date = BanglaDateTime::create('2023-04-13');
echo 'Set Time with Bangla format: ' . $date->format('l jS F Y h:i:s');

echo '<br>';

// Create a BanglaDateTime instance with a custom date ('2023-04-13'), converted to the Bangla calendar
$date = BanglaDateTime::create('2023-04-13');
echo 'Set Time & converted to Bangla: ' . $date->toBangla('l jS F Y h:i:s');

// Create a BanglaDateTime instance with the current time and a specific timezone ('Asia/Dhaka'), formatted in Bangla locale
$date = BanglaDateTime::create('now', 'Asia/Dhaka');
echo 'Set Time & Time Zone with Bangla format: ' . $date->format('l jS F Y h:i:s');

echo '<br>';

// Create a BanglaDateTime instance with the current time and a specific timezone ('Asia/Dhaka'), converted to the Bangla calendar
$date = BanglaDateTime::create('now', 'Asia/Dhaka');
echo 'Set Time & Time Zone & converted to Bangla: ' . $date->toBangla('l jS F Y h:i:s');

    $date = bangla_date_time('2023-04-13', 'Asia/Dhaka');
    

    echo format_bangla_date('l jS F Y h:i:s');
    

    echo convert_to_bangla_calendar('l jS F Y h:i:s');
    
bash
composer