FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > PHP, Perl, Python and/or MySQL
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 04-08-2002, 01:19 PM   Postid: 65381
Benson
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Dec 1998
Location: NC, USA
Posts: 478
Age calculation with PHP

I found this little bit of PHP code that will display a person's age in a web page. How can I change it so that the result will be "12" instead of "12.02345"?


Code:
<?php 
    $dofb = strtotime ("2 November 1980"); // date to calculate from
    $age = strtotime ("now")-$dofb;
    $age_in_years = $age/31557600; // 31557600 seconds in a year
    echo "$age_in_years"; 
?>
Benson is offline   Reply With Quote
Old 04-08-2002, 01:32 PM   Postid: 65382
Benson
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Dec 1998
Location: NC, USA
Posts: 478
I found it (yea!)

Code:
<?php 
    $dofb = strtotime ("2 November 1980"); // date to calculate from
    $age = strtotime ("now")-$dofb;
    $age_in_years = $age/31557600; // 31557600 seconds in a year
    $current_age = floor($age_in_years);
    echo "$current_age";
	
?>
Benson is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:54 AM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.