akr4m/bangla-datetime-format
Composer 安装命令:
composer require akr4m/bangla-datetime-format
包简介
Extended DateTime Class For Bangla Date and Time
README 文档
README
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 BanglaDatetimeFormat\Types\BnDateTime; use BanglaDatetimeFormat\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;
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 BanglaDatetimeFormat\Types\DateTime Class to distinguish between native DateTime Class.
use BanglaDatetimeFormat\Types\DateTime as EnDateTime;
Methods/Features
Both BanglaDatetimeFormat\Types\DateTime and BanglaDatetimeFormat\Types\BnDateTime has the member functions as native DateTime class.
DateTime
- you can use
enFormatfunction to get output in english.
BnDateTime
BanglaDatetimeFormat\Types\BnDateTimegot 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
bwhich will print ('ভোর', 'সকাল', 'দুপুর', 'বিকাল', 'সন্ধ্যা', 'রাত') - Use
setDate($year, $month, $day)to set bengali date getDateTimemethod will return object ofBanglaDatetimeFormat\Types\DateTimefor current object.
Cookbook
English date in Bangla
<?php use BanglaDatetimeFormat\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 BanglaDatetimeFormat\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 BanglaDatetimeFormat\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 BanglaDatetimeFormat\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 BanglaDatetimeFormat, 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:
- Fork the project.
- Branch out into a new branch.
git checkout -b name_of_new_feature_or_bug - Make your feature addition or bug fix.
- Add tests for it. This is important so I don’t break it in a future version unintentionally.
- Commit.
- Send me a pull request!
Some Similar PHP libraries you may like to see:
akr4m/bangla-datetime-format 适用场景与选型建议
akr4m/bangla-datetime-format 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 68 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 05 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Bangla DateTime」 「Bangla Date」 「Bangla」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 akr4m/bangla-datetime-format 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 akr4m/bangla-datetime-format 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 akr4m/bangla-datetime-format 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Tools to convert between .NET and PHP date formats
Time provider, providing consistent current date, time, datetime and timezone across the request.
Adds the EDTF data type to Wikibase
Datetime helpers for timezone handling
A Laravel package for converting English numbers into Bangla digits, Bangla words, Bangla month names, and Bangla money format with an easy-to-use API.
Extended DateTime Class For Bangla Date and Time
统计信息
- 总下载量: 68
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-20
