/    Sign up×
Community /Pin to ProfileBookmark

date diff problem

Below is the complet function and the string of code that I’m trying to use to calculate a persons age.

It not wanting on my web server, for some reason when it gets to the point to exicute the string to calcualte the age the code stops runing. everythingis displayed until this point but nothing after. there are no error message shown either.

Any idea why this is happening.

Thank you

[code=php]
<?
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
$end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
return $end_date – $start_date;
}

?>
[/code]

[code=php]
$ownerAge = floor(dateDiff(“-“, date(“Y-m-d”), $dob)/365);
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@legendxNov 25.2006 — [code=php]
<?
function dateDiff($dformat, $endDate, $beginDate)
{
return strtotime($endDate) - strtotime($beginDate);
}

?>
[/code]


This will give you the difference in seconds, just divide by the appropriate number to get months/years/weeks whatever you need.
Copy linkTweet thisAlerts:
@kprocauthorNov 25.2006 — I tured all error reporting on and I get

Fatal error: Call to undefined function: gregoriantojd() in /services/webpages/f/a/familyclick.ca/public/familyConfig.php on line 6

all my date formats are Y,m,d
×

Success!

Help @kproc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...