2018-11-09 Pujan Niroula 2 Minute(s) Read

Nepali Date [AD-BS] Converter in PHP

img-open source ad bs.png

If someone says I celebrate my birthday 3 times in a year then he must be lying or he must be Nepalicool. 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.laughing According to vedic astrology a famous astrologer suggested its name - Nepali Date Converter. tongue-out 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.

Download Attached Files: Nepali Date Converter [Open Source].zip
Comments (51) Add New Comment
Kingcamp Camping Gear Table2024-06-17 1:20 PM

9 Things Your Parents Teach You About Best Online Shopping Sites London Kingcamp Camping Gear Table

Reply
Slot Promotions2024-06-16 3:18 AM

The 10 Most Scariest Things About Slot Promotions Slot Promotions

Reply
Thick Bully Pizzle2024-06-16 1:18 AM

The Most Successful Top 10 Online Shopping Sites In Uk For Clothes Experts Have Been Doing 3 Things Thick Bully Pizzle

Reply
upvc window repair near Me2024-06-15 5:26 PM

It's Time To Expand Your Replacement Upvc Window Handles Options upvc window repair near Me

Reply
Ghost immobiliser problems2024-06-14 3:28 AM

See What Ghost Immobiliser Problems Tricks The Celebs Are Using Ghost immobiliser problems

Reply
rendingnicheblog.top2024-06-14 2:03 AM

Here Is The You Can Move Web Site To Ones Domain (Part 2) rendingnicheblog (rendingnicheblog.top)

Reply
Rack Mount Shelf Slides2024-06-13 10:46 PM

Five People You Need To Know In The List Of Online Shopping Sites In Uk Industry Rack Mount Shelf Slides

Reply
Peakpulsesite.Top2024-06-13 3:37 AM

Powerful Blog Seo Assist In Improve Your Google Ranking Peakpulsesite (Peakpulsesite.Top)

Reply
Bravo Case2024-06-12 5:57 PM

11 Methods To Redesign Completely Your CSGO Cases Highest Roi Bravo Case

Reply
dashdome2024-06-12 2:07 PM

How Turn Into An Expert Blog Writer dashdome

Reply
aqueon shrimp Care2024-06-12 11:04 AM

What Is The Reason? Amazon Uk Online Shopping Clothes Is Fast Increasing To Be The Hottest Trend Of 2023? aqueon shrimp Care

Reply
slotcoin2024-06-12 5:41 AM

You Wrote A New Blog Post, Now What Normally? slotcoin

Reply
window replacement near me2024-06-12 3:35 AM

The Top 5 Reasons Why People Are Successful In The Double Glazed Window Repair Industry window replacement near me

Reply
Rentry.Co2024-06-11 11:53 PM

5 Killer Quora Answers On How Much Are Spare Car Keys How Much Are Spare Car Keys (Rentry.Co)

Reply
Prisma case2024-06-11 8:36 PM

11 Ways To Completely Redesign Your CSGO Cases To Invest In Prisma case

Reply
Georgia2024-06-11 1:42 PM

You'll Never Be Able To Figure Out This Avon Skin So Soft Oil's Secrets avon skin so soft oil (Georgia)

Reply
Best Online Clothing Sites Uk2024-06-11 11:11 AM

The 9 Things Your Parents Taught You About Best Online Clothing Sites Uk Best Online Clothing Sites Uk

Reply
blogpulse.Top2024-06-11 6:08 AM

Blog Optimization Tips blogpulse, blogpulse.Top,

Reply
online shopping uk discount2024-06-11 3:09 AM

Guide To Online Shopping Uk Discount: The Intermediate Guide The Steps To Online Shopping Uk Discount online shopping uk discount

Reply
second hand double buggy2024-06-10 10:14 PM

See What Second Hand Double Buggy Tricks The Celebs Are Utilizing second hand double buggy

Reply
Blog2024-06-09 11:20 PM

Work In A Home Office Tips - Blogging For Online Income Blog

Reply
coinsslot.Com2024-06-09 10:24 PM

What's A Blog? Why Should I Get Blogging Services? coinsslot (coinsslot.Com)

Reply
Vimeo.Com2024-06-09 6:11 PM

11 Ways To Destroy Your Amazon Online Shopping Clothes Uk Durable Kitchen Cutting Board [Vimeo.Com]

Reply
escape rooms list2024-06-09 5:48 PM

Hi there! Do you know if they make any plugins to assist with Search Engine Optimization? I'm trying to get my site to rank for some targeted keywords but I'm not seeing very good results. If you know of any please share. Cheers! I saw similar art here: Escape room

Reply
Nexusnook.top2024-06-09 4:13 PM

How Generate A List With Your Blog - Easy Tips To Acquire Started nexusnook (Nexusnook.top)

Reply
Welcome Kit2024-06-09 4:21 AM

Five Killer Quora Answers To Welcome Kits Welcome Kit

Reply
Umesh Gaire2024-06-03 5:16 AM

Please help me to generate nepali date like this: 2081-02-21 in AD we can do with date('Y-m-d'); I hope you understood what I am expecting.

Reply
Ramesh2023-08-21 11:25 AM

Invalid Year range, when selected day 32 of the month

Reply
Laxman Adhikari2023-04-10 2:57 PM

hello i what to know how array of months is calculated .

Reply
Njn Khanal2022-11-19 7:51 AM

At first thank you so much for this, everything working well but when converting to nepali date month end like kartik 31 its showing mansir 1

Reply
Muniraj Rajbanshi2021-05-13 7:56 AM

How to get two digit year ?

Reply
Pujan Niroula2021-05-30 6:07 PM

No option, you can trim first two digit :) get your hands dirty

Sujan Stc2021-04-14 2:29 PM

If you are facing problem tallying nepali date and english date with 'Asia/Kathmandu' timezone, use timezone_open('UTC') on every date_create function like so: $date_start=date_create($this->firstday_en,timezone_open('UTC')); This will perfectly tally with english time and you dont have to change to UTC if your site is already using 'Asia/Kathmandu' timezone.

Reply
Pujan Niroula2021-05-30 6:08 PM

Thanks :)

Gopal Nepal2020-09-18 11:05 AM

Hello sir, I want to display format like this २०७७ असोज २ . But, find format for month not for year and day. How to do that ?

Reply
Pujan Niroula2020-09-29 2:59 AM

You can convert output date to devanagari Numbers with this function <?php function devanagari($num) { $num_nepali = array('०','१','२','३','४','५','६','७','८','९'); $num_eng = array('0','1','2','3','4','5','6','7','8','9'); $nums = str_replace($num_eng, $num_nepali, $num); return $nums; } echo devanagari('13905'); //Output १३९०५ ?>

John Doe2020-06-28 3:46 AM

Does anybody has ad-bs converter in javascript

Reply
Hiramani Pun2020-06-03 10:20 AM

today is 2020/06/03 and in nepali 2077/02/21, its showing nepali date 2077/2/20 , what's the problem ?

Reply
Sujan Stc2021-04-14 2:31 PM

Simple solution is above at my comment. Please check.

Pujan Niroula2020-06-03 1:06 PM

Set timezones to UTC. Place date_default_timezone_set('UTC'); before require("nepali-date.php");

Ankit Subedi2020-01-16 5:06 AM

First of all, thank you so much for the converter. But, I have a problem. The code works perfectly fine on localhost, but shows "Fatal error: Uncaught Error: Call to undefined function cal_days_in_month()" this error when deployed. Is there anything i am missing?

Reply
Pujan Niroula2020-01-17 4:54 PM

Sorry! I can't do anything for that. Looks like server side problem. :(

Yogendra2019-12-05 5:49 PM

I have been trying to use your code but it is returning the non numeric error and couldnot use it.could you please help out

Reply
Pujan Niroula2019-12-10 9:06 AM

I have updated the code. Please check, thanks :)

InNepall2019-11-06 4:14 AM

Can you please update the code. I am getting an error with PHP 7.3 "Warning: A non-numeric value encountered in ../nepali-date.php on line 190" Thank you for sharing your hard work.

Reply
Pujan Niroula2019-12-10 9:11 AM

I have updated the code, Please check thanks for your patience. :) Anyway there was little problem on 186 line. Compare to find out more :-D

Binod Stha2018-11-13 5:22 AM

Hi, Thanks for sharing. Please share your nepali date converter's full code also.

Reply
Baha2019-09-10 4:03 AM

https://github.com/bahadurbaniya/Date-Converter-Bikram-Sambat-to-English-Date full code in Java here.

Pujan Niroula2018-12-13 8:44 AM

Sorry for late reply... Currently we don't have plan to share these scripts, In future we will... Hope you understand...