I need to compare Bikram Sambat dates in PHP. Lets say today in AD is 2012-08-03, the BS date today is 2069-04-19. In BS, we have total number of days in a month ranging from 29 to 32. Again, the days are not consistent in every year. Example if this year current month have 31 days, next year same month might have 30 or even 32 days.
The way i could think is, using a php date converter class (which I already have), convert given BS Dates to equivalent AD Dates and compare them. Just i want to know is there any other better way to do this without using the class i have??
By saying comparing here I mean
a) Finding days between the given date ranges.
b) Checking whether a date lies on a given two date ranges
c) And other comparisons we could do with AD dates using php Date Function
thanks any help is highly appreciated.
Generally, I would suggest converting both dates to unix timestamps (seconds since 1970-1-1 AD) which is a simple integer value for comparison.
Apparently, there is no simple logic behind BS so you will not be able to find an analytic expression that directly gets you from here to there. If you do not wish to use an external class you could write some sort of (recursive) function that starts from 1970-1-1 AD which you manually convert to BS and counts up the timestamp from there following the rules for BS.