i want to get the age of the people. i get it in the form as the date of birth 0000/00/00.
when i do a report, how do i get the age.
thanks...
calculate difference in dates
Moderator: General Moderators
-
alexislalas
- Forum Commoner
- Posts: 44
- Joined: Sun Feb 19, 2006 10:09 pm
look at this old post:
viewtopic.php?t=39916&start=0
it's not exactly what you're looking for, but will get you started on the right foot
viewtopic.php?t=39916&start=0
it's not exactly what you're looking for, but will get you started on the right foot
You should use something similar to the following to break apart the date into month, day and year elements.
$today = date("Y-m-d");
$d = explode(" ",$today);
$date1 = $d[0];
$date_x = explode("-",$date1);
$year = $date_x[0];
$month = $date_x[1];
$day = $date_x[2];
So if you had the date 2004-06-24, the variables would be set to:
$year = 2004
$month = 06
$day = 24
From here you can perform basic math equations on the variables. Hope this helps.
Regards,
Cody Singsaas
IE Internet Solutions
http://www.ieinternetsolutions.com
$today = date("Y-m-d");
$d = explode(" ",$today);
$date1 = $d[0];
$date_x = explode("-",$date1);
$year = $date_x[0];
$month = $date_x[1];
$day = $date_x[2];
So if you had the date 2004-06-24, the variables would be set to:
$year = 2004
$month = 06
$day = 24
From here you can perform basic math equations on the variables. Hope this helps.
Regards,
Cody Singsaas
IE Internet Solutions
http://www.ieinternetsolutions.com
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Please, when posting PHP, wrap it in
So if you had the date 2004-06-24, the variables would be set to:
From here you can perform basic math equations on the variables. Hope this helps.
Regards,
Cody Singsaas
IE Internet Solutions
http://www.ieinternetsolutions.com[/quote][/syntax]
Code: Select all
bbcode tags.
[quote="csingsaas"]You should use something similar to the following to break apart the date into month, day and year elements.
[syntax="php"]<?php
$today = date("Y-m-d");
$d = explode(" ",$today);
$date1 = $d[0];
$date_x = explode("-",$date1);
$year = $date_x[0];
$month = $date_x[1];
$day = $date_x[2];
?>Code: Select all
<?php
$year = 2004
$month = 06
$day = 24
?>
Regards,
Cody Singsaas
IE Internet Solutions
http://www.ieinternetsolutions.com[/quote][/syntax]