If someone says I celebrate my birthday 3 times in a year then he must be lying or he must be Nepali. First birthday according to Bikram Sambat date, Second according to After Christ (AD) and third one according to tithi (Lunar Date) system. In this post I will discuss just about two date system and share Free AD-BS Converter in PHP. Because of government and society we must use BS date system and for internet we must use AD date system. Let's make it easy with this wonderful AD/BS converter.
Developing Nepali Date Converter Script
As I mentioned on my first post during daily new idea development period I thought to add multi date system in this So Called CMS. I googled and found desired converter but that has date limitation. If my grandfather want to convert his birthday then it will shows error. So I decided to write my own Nepali date converter in PHP for this blog. You can change date system and language of this blog from Site Setting.
It's completely based on arrays and date system of PHP. I have collected data from different sources. It's little boring to collect the correct data and use those data. I wrote it in very simple way based on counting days between dates. I thought it as most effective idea.
How to Use Nepali Date[ad/bs] Converter on Your Website?
Simply download and upload it to your server. Include it where you want to use. For eg. if you have to display it on index file and include it there and call for action... See my example below. If you want to display time too then use echo $date['l']; (Small L). and you can echo month name or month number by changing Case of $date['m']. Simply I can say you can use pretty same as date() function in PHP, 'm' means month number, 'M' mean month name etc...
How to store time on database for this converter?
It's simple just store time(). This function returns the current time in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
How I Used This PHP Script?
I used it in very simple way. here is my code
$y = date('Y', time()); //Getting Year
$m = date('m', time()); //Getting Month
$d = date('d', time()); //Getting Day
require('nepali-date.php'); //Including library
$date = new nepali_date;
$date = $date->get_nepali_date($y, $m, $d);
echo $date['y'].'-'.$date['m'].'-'.$date['d']; //Printing Date
Lets describe it.
First I got current AD date (Year, Month and day). and called the class and this converter did rest and finally I print all dates.
Wishing Birthday on Nepali[B.S] Dates
If you own sites which is build for Nepali People then you want to wish them on Nepali Date but PHP doesn't support Bikram Sambat date system. Here you can use this to wish them. Store Nepali Date on database and Check today's date with this script. If month and date matched wish them. I have attached full code along with the script.
 Naming This
I almost forgot to name this item. According to vedic astrology a famous astrologer suggested its name - Nepali Date Converter. Further he added this name will be beneficial for SEO purpose too. Some astrologers suggested AD/BS date converter but According to market I thought the first one will be great.
Example
You can Check this free Online Nepali Date Converter based on this script.
 Thanks for reading... Glad to see you in comment section below.