Jump to content


Photo

Days between 2 dates


  • Please log in to reply
2 replies to this topic

#1 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 22 March 2006 - 09:31 PM

I have a users table and within that I have a field that places the date the member registersd.

What I need is a way to show on a web page the number of (full) days they have been registered for.

I've already connected to the database and pulled out the date, giving it the name $regdate

I know that i need to simply take $regdate from the current date but im left with a long number as this is not formatted, think its the number of seconds they've been a member, rather than days.

Currently using:
$daysold = (date() - $regdate);
to work this out.

Anyone know how I can

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 22 March 2006 - 09:49 PM

SELECT ( TO_DAYS(CURDATE()) - TO_DAYS(reg_date)) as days_reg FROM users

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 23 March 2006 - 01:26 AM

Your a star - thank you!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users