PHP Classes
elePHPant
Icontem

Easy PHP Bangla Date: Extends DateTime class to format Bangla dates

Recommend this page to a friend!
  Info   View files Documentation   Screenshots Screenshots   View files View files (24)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-05-02 (11 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 60 This week: 1All time: 9,413 This week: 372Up
Version License PHP version Categories
easy-bangla-date 1.0.3Custom (specified...5.3Localization, PHP 5, Time and Date
Description Author
This package is specific mainly for applications used in Bangladesh Bangladesh .

This package extends DateTime class to format Bangla dates.

It can take as parameters a given date and time string in a regular format accepted by PHP DateTime format.

The package can format the given date and time using Bangla characters and format rules.

  Performance   Level  
Name: Roni is available for providing paid consulting. Contact Roni .
Classes: 7 packages by
Country: Bangladesh Bangladesh
Age: ???
All time rank: 369748 in Bangladesh Bangladesh
Week rank: 15 Up1 in Bangladesh Bangladesh Up
Innovation award
Innovation award
Nominee: 2x

Details

Easy Bangla Date

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version Total Downloads

Utility Library to Display Bangla Date and Time.

Key Features

  • Easy to use
  • Works same as php native DateTime Class
  • Support almost all format option like DateTime class
  • Can customize the start of day hour by setting morning option(for BnDateTime)
  • Can be used to convert English-Bangla-English date format

Synopsis

<?php
use EasyBanglaDate\Types\BnDateTime;
use EasyBanglaDate\Types\DateTime as EnDateTime;

require 'autoload.php'

$bongabda = new BnDateTime('2016-04-22 05:26:47 pm', new DateTimeZone('Asia/Dhaka'));
$bongabda->setDate(1398, 1, 1);

echo $bongabda->format('l jS F Y b h:i:s') . PHP_EOL ;
echo $bongabda->enFormat('l jS F Y h:i:s a') . PHP_EOL;
echo $bongabda->getDateTime()->format('l jS F Y b h:i:s'). PHP_EOL;
echo $bongabda->getDateTime()->enFormat('l jS F Y h:i:s A') . PHP_EOL;

Output

Installation/Usage

If you're using Composer to manage dependencies, you can include the following in your composer.json file:

"require": {
    "ronisaha/easy-bangla-date": "dev-master"
}

Then, after running composer update or php composer.phar update, you can load the class using Composer's autoloading:

require 'vendor/autoload.php';

Otherwise, you can simply require the given autoload.php file:

require_once 'PATH_TO_LIBRARY/autoload.php';

And in either case, I'd suggest using an alias for EasyBanglaDate\Types\DateTime Class to distinguish between native DateTime Class.

use EasyBanglaDate\Types\DateTime as EnDateTime;

Methods/Features

Both EasyBanglaDate\Types\DateTime and EasyBanglaDate\Types\BnDateTime has the member functions as native DateTime class.

DateTime
  • you can use enFormat function to get output in english.
BnDateTime
  • EasyBanglaDate\Types\BnDateTime got extra method setMorning to define a hour for start of day. By default day start at 6.
  • Along with all format options of native DateTime class, we have extra option b which will print ('???', '????', '?????', '?????', '???????', '???')
  • Use setDate($year, $month, $day) to set bengali date
  • getDateTime method will return object of EasyBanglaDate\Types\DateTime for current object.

Cookbook

English date in Bangla

<?php
use EasyBanglaDate\Types\DateTime;

require 'autoload.php'

$date = new DateTime('now', new DateTimeZone('Asia/Dhaka'));

echo $date->format('l jS F Y b h:i:s');

Native format functionality

<?php
use EasyBanglaDate\Types\DateTime;

require 'autoload.php'

$date = new DateTime('now', new DateTimeZone('Asia/Dhaka'));

echo $date->enFormat('l jS F Y b h:i:s');

Convert English to Bangla Date

<?php
use EasyBanglaDate\Types\BnDateTime;

require 'autoload.php'

$bongabda = new BnDateTime('now', new DateTimeZone('Asia/Dhaka'));

echo $bongabda->format('l jS F Y b h:i:s');

Convert Bangla to English Date

<?php
use EasyBanglaDate\Types\BnDateTime;

require 'autoload.php'

$bongabda = new BnDateTime('now', new DateTimeZone('Asia/Dhaka'));

echo $bongabda->format('l jS F Y b h:i:s');
//Set Bengali date
$bongabda->setDate(1405,1,1);
//Get english date in bangla
echo $bongabda->getDateTime()->format('l jS F Y b h:i:s');
//Get english date in english
echo $bongabda->getDateTime()->enFormat('l jS F Y h:i:s');

Contributing to Library

If you find a bug or want to add a feature to EasyBanglaDate, great! In order to make it easier and quicker for me to verify and merge changes in, it would be amazing if you could follow these few basic steps:

  1. Fork the project.
  2. Branch out into a new branch. git checkout -b name_of_new_feature_or_bug
  3. Make your feature addition or bug fix.
  4. Add tests for it. This is important so I don?t break it in a future version unintentionally.
  5. Commit.
  6. Send me a pull request!

Some Similar PHP libraries you may like to see:

  • https://github.com/mhmithu/bangla-date-and-time
  • https://github.com/tareq1988/bangla-date
  • https://github.com/shahalom/translate-date-in-bangla
Screenshots  
  • screenshot.jpeg
  Files folder image Files  
File Role Description
Files folder imageCommon (1 file)
Files folder imageTests (1 file, 4 directories)
Files folder imageTools (3 files)
Files folder imageTypes (2 files)
Accessible without login Plain text file .coveralls.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file autoload.php Aux. Auxiliary script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Example script
Accessible without login Plain text file README2.MD Doc. Documentation

  Files folder image Files  /  Common  
File Role Description
  Plain text file BaseDateTime.php Class Class source

  Files folder image Files  /  Tests  
File Role Description
Files folder imageResources (5 files)
Files folder imageTools (1 file)
Files folder imageTypes (2 files)
Files folder imageUtils (1 file)
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script

  Files folder image Files  /  Tests  /  Resources  
File Role Description
  Accessible without login Plain text file bn_conversion_data.csv Data Auxiliary data
  Accessible without login Plain text file bn_flag_data.csv Data Auxiliary data
  Accessible without login Plain text file bn_flag_data_in_en.csv Data Auxiliary data
  Accessible without login Plain text file bn_flag_t_data.csv Data Auxiliary data
  Accessible without login Plain text file en_flag_data.csv Data Auxiliary data

  Files folder image Files  /  Tests  /  Tools  
File Role Description
  Plain text file ConverterTest.php Class Class source

  Files folder image Files  /  Tests  /  Types  
File Role Description
  Plain text file BnDateTimeTest.php Class Class source
  Plain text file DateTimeTest.php Class Class source

  Files folder image Files  /  Tests  /  Utils  
File Role Description
  Plain text file CsvFileIterator.php Class Class source

  Files folder image Files  /  Tools  
File Role Description
  Plain text file BanglaCalender.php Class Class source
  Plain text file Converter.php Class Class source
  Plain text file MagicNumbers.php Class Class source

  Files folder image Files  /  Types  
File Role Description
  Plain text file BnDateTime.php Class Class source
  Plain text file DateTime.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 96%
Total:60
This week:1
All time:9,413
This week:372Up