Bangla date as a PHP class

I have worked with Bangla date a long time ago. The first initiative was to make a extension for forum engine punBB. After that, i made a javascript widget to display Bangla date in any site. The third initiative was to make a facebook application that shows current Bangla date to your facebook profile.

I always wanted to publish this as a PHP Class but never got that chance to do so. After a long time i worked with Bangla date today and finally created a PHP Class to use it anywhere by anyone. Sorry for the late.

Usage:

<?php
include_once 'class.banglaDate.php';
$bn_date = new BanglaDate(time());
$date = $bn_date->get_date();
?>

You will get an array of converted date in Bangla.

A few things needed to know. Bangla date counted or changes after the sun rise. That means, where English date changes at 12′O clock at the night, Bangla date changes at the morning after the sunrise.

Class Constructor:
This class constructor has 2 parameters. The first one in timestamp and the second one is the hour of changing the date. If you want to change the Bangla date like English at 12’0 clock at the night, you should use $bn_date = new BanglaDate(time(), 0). But if you want to change the date at 6′O clock at the morning, use as $bn_date = new BanglaDate(time(), 6). If you don’t pass the second parameter, the default value is 6. Use as you like.

After Creating the class object, you can set another date using set_time() like $bn_date->set_time(time(), 4);

Bangla Date class on PHPClasses.org

যে কোন সাইটে দেখান বাংলা তারিখ

আপনারা জানেন, পানবিবির জন্যে আমি বাংলা তারিখের একটা এক্সটেনশন বানিয়েছি। তারপর চিন্তা করলাম যে কোন সাইটে লাগানোর ব্যবস্থা করলে মন্দ হয় না। তাই, সব ওয়েব সাইটে যাতে বাংলা তারিখ দেখানো যায় সেই জন্যে আজ একটা জাভাস্ক্রিপ্ট উইজেট বানালাম। শুধু যেকোন পাতায় নিচের কোডটুকু পেস্ট করে দিন। ব্যস, আপনার সাইটে বাংলা তারিখ দেখুন।

<script type="text/javascript" src="http://tareq.wedevs.com/bangla_date_widget.php">
</script>

উদাহরণঃ

punBB 1.3.2 extension: Bangla Date (বঙ্গাব্দ)

বাংলা আমাদের মাতৃভাষা। এই ভাষার জন্যে আমরা যুদ্ধ করেছি। কিন্তু বাঙালী হলেও আমরা অধিকাংশ লোকই জানিনা আজকে বাংলা কত তারিখ। তাই আজকে জনপ্রিয় ফোরাম ইঞ্জিন পানবিবি’র জন্যে একটা এক্সটেনশন বানালাম। এই এক্সটেনশন আপাতত ব্যবহার করা হচ্ছে একটি অত্যন্ত জনপ্রিয় বাংলা ফোরাম প্রজন্মতে। ডিফল্টভাবে এটি ফোরামের Description এর সোজা ডানদিকে প্রদর্শিত হয়। নিচের স্ক্রিনশট দেখুন

bangla-date1

এটি প্রতিদিনের বাংলা তারিখ ফোরামের header এ দেখায়। সামনে পহেলা বৈশাখ আসছে, সে উপলক্ষ্যে এটি রিলিজ দেয়া হল। আসলে এই এক্সটেনশনের আইডিয়াটি ছিল রাজু ভাইয়ের। তিনি আমাকে বলাতে আমি এই এক্সটেনশনটি বানিয়েছি। ধন্যবাদ রাজু ভাইকে।

আপডেট(২৯ এপ্রিল): আজ এর নতুন ভার্সন ১.২ রিলিজ দিলাম। আগের ভার্সনে কিছু বাগ ছিল। যেমনঃ ঐটার সাল নিয়ে একটু ঝামেলা হচ্ছিল। ঠিক মত আপডেট হচ্ছিল না। তাই এর নতুন ভার্সনে এটা ঠিক করে দেয়া হয়েছে।

আরেকটা নতুন ফিচার যুক্ত করা হয়েছে। যেহেতু বাংলা তারিখ গণনা করা হয় সূর্যোদয় থেকে, তাই নতুন ভার্সনে সকাল ৬ টা থেকে তারিখ পরিবর্তিত হবে। অর্থাৎ রাত ১২ টার পরিবর্তে সকাল ৬ টা থেকে তারিখ পরিবর্তিত হবে।