Re: Re: date calculation

From: Date: Sun, 16 Feb 2003 20:45:53 +0000
Subject: Re: Re: date calculation
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-135780@lists.php.net to get a copy of this message
No I am not using msql "Olinux" <olnx@yahoo.com> wrote in message news:20030216172856.68083.qmail@web11803.mail.yahoo.com... > If you're using a database, it may be able to take > care of this for you. If you're using mysql: > > 6.3.4 Date and Time Functions > http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Dat e_and_time_functions > > olinux > > > --- Fred Merritt <fred@argus.pt> wrote: > > Qt, > > The easiest way is to convert your dates into a > > serial day number(i.e. > > the number of days that have elapsed between your > > date, and some > > arbitrary date in the dim and distant past - I think > > PHP uses 25th > > November, -4714). There are some calendar functions > > in php that will do > > this for you. Once you have your dates as a numeric > > offset, you can > > subtract them to get a the number of days between > > the dates, or you can > > add or subtract a number of days to get a new > > offset. Once you have the > > new offset, there are reverse calendar functions in > > php, to convert your > > new offset back to a calendar date. > > > > Check out the functions GregorianToJD(), and > > JDToGregorian(), in the > > Calendar functions of the PHP manual. If you do not > > have access to the > > calendar functions in your version of php, there are > > also a couple of > > examples how to do one of the conversions written in > > PHP, in the user > > contributed notes of the manual. There are also > > many published articles > > describing algorithms on how to do this. I can > > remember implementing > > these functions in 1977(Not in PHP of course), from > > an article published > > in the journal of the ACM, in 1963. > > > > Hope this helps. . . Fred > > > > Qt wrote: > > > Dear Sirs, > > > > > > How can I add or subtract two date easily. Is > > therea any lib or function > > > about this. I can not find any easy way in the > > manual > > > > > > Best Regards > > > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Shopping - Send Flowers for Valentine's Day > http://shopping.yahoo.com

« previous php.general (#135780) next »