View Full Version : Finding out the days between 2 timestamps

01-16-2004, 10:04 PM
I'm sorry if this question already exists in these forums, I did try searching but found nothing........

Anyway..... Say I have a ''bigint(20)" field in a mysql table, which holds a future timestamp using the time() function..
Now, I would like to return the number of days from that field to the current date using time()...

For example: You have 25 days left.......

Example code which goes into the table:
( $member_expire_date = time() + (86400 * 25); )

I know its simple, I'm just an amateur PHP coder (at the moment), so any assistance will be apreceiated.

Hope you understood my question

01-17-2004, 12:08 AM
do it thru MySQL:

"SELECT (TO_DAYS(FROM_UNIXTIME(datefield))-TO_DAYS(NOW())) AS daydiff FROM thetable"