Hello there,
I'm trying to convert a users date in the database into their age using the following:
<?php
//calculate years of age (input string: YYYY-MM-DD)
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}
$date1 = date('d-m-Y');
$date2 = $row_filteredUsersInRange['date_birthday'];
print " . dateDiff("-", $date2, $date1) . ";
?>
However, the age always appears as 0 and then i get the error: Fatal error: Cannot redeclare datediff() (previously declared in /home/hacs/FRSI2ZHA/htdocs/postcode-uk/postcode-results.php:285) in /home/hacs/FRSI2ZHA/htdocs/postcode-uk/postcode-results.php on line 285
Line 285: function dateDiff($dformat, $endDate, $beginDate)
Also, the date in the database is in the format: YYYY-MM-DD 00:00:00
If anyone can help that would be great