>> Is there any function avialable in PHP to calculate
>> the no of days by passing 2 dates
>>
If you happen to be pulling both dates from MySQL you could use the MySQL date functions:
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html
http://dev.mysql.com/doc/mysql/en/Date_calculations.html


If that is not possible and you don't/can't use the Pear Date library recommended previously you could do date arithmetic using unix timestamps. So, take the timestamp of 1/1/2005 and subtract the timestamp of 1/2/2004. That will give you the number of seconds between the two dates and from there you can figure out how many days are between the two.

- Jamie


Hi

Is there any function avialable in PHP to calculate
the no of days by passing 2 dates like 1 argument is
1/1/2005 and the second one is 1/2/2005 then it
returns the no of days or how can i do that if there
is no builtin function .

Regards
Khuram Noman



Maybe you can try the pear Date package - it has some handy function
that does exactly what you're asking for:

http://pear.php.net/package/Date/docs/1.4.2/apidoc/Date-1.4.2/Date_Calc.html#methoddateDiff


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to