Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I cacluate days old in php? 1

Status
Not open for further replies.

linuxMaestro

Instructor
Jan 12, 2004
183
US
How do I cacluate days old in php?

I tried:
$born="2005-02-16";
$today=date("Y-m-d);
$diff=$today-$born;

But it gives 0 all the time.
 
Code:
$born=strtotime("2005-02-16");
$today=strtotime("now");
$diff=$today-$born; //seconds
$numdays = $diff/(60*60*24);

echo "$numdays days difference";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top