how to calculate the days according to date.. ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

how to calculate the days according to date.. ?

Post 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 ..
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

That may help you:

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

Or you may use strtotime() function.
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

how to calculates the day

Post by djdon11 »

Hi

sorry these functions are not working in PHP... :(
do you have any other idea.. ?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post 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?
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

how to calculate the days

Post by djdon11 »

The format is date......
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Code: Select all

$daysLeft = round( (strtotime($end_date) - time() )/(60*60*24));
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

how to calculate days remaining

Post by djdon11 »

Hello friend..

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