Page 1 of 1

how to calculate the days according to date.. ?

Posted: Tue Jul 31, 2007 2:11 pm
by djdon11
Hi Friends ....

i have a subscription method on my site ... subscription for three months . now i have to show the days remaining on the page of user .. i have date activated of user & date valid for the subscription in the database .. now to show the days remaining on the page of user what i should i adapt is there is any function in PHP which calculates the days according to the two dates by substraction operation over them .... ???

please help me if anybody can ...

Thanks
waiting for reply ..

Posted: Tue Jul 31, 2007 2:22 pm
by VladSun
That may help you:

http://lwest.free.fr/doc/php/lib/date-en.html#sec_37

Or you may use strtotime() function.

how to calculates the day

Posted: Tue Jul 31, 2007 2:31 pm
by djdon11
Hi

sorry these functions are not working in PHP... :(
do you have any other idea.. ?

Posted: Tue Jul 31, 2007 2:46 pm
by VladSun
Yes ;)
Download and install tha package - links are on the top of the page I've pointed to you :)

PS:
BTW, what is the format of the dates in your DB - timestamp, date, datetime?

how to calculate the days

Posted: Tue Jul 31, 2007 3:01 pm
by djdon11
The format is date......

Posted: Tue Jul 31, 2007 3:25 pm
by VladSun

Code: Select all

$daysLeft = round( (strtotime($end_date) - time() )/(60*60*24));

how to calculate days remaining

Posted: Tue Jul 31, 2007 3:58 pm
by djdon11
Hello friend..

it is working now .. thank you very much :)