473,396 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem with this age validator - workarounds?

Hello, I am trying to find a workaround for the Unix date issue to
calculate ages based on a persons birthdate and the current date. Here
is the code I am working with now,

<?php

$dob = "10 July 1981";
$dob = strtotime($dob);

$today1 = strtotime ('now');
$today=date("d.m.Y",$today1);
$f_date1 = $person_dob;
$f_date=date("d.m.Y",$f_date1);

$difference = intval(((($f_date1 - $today1)/86400+1)*-1)/365);

print $difference;

?>

This obvisouly will work, until I start inputting birthdates pre-1970.
Is there something better (that is accurate) which will calculate &
accept the long birthdate format I am using here?

Jul 17 '05 #1
2 1378
I noticed that Message-ID:
<11**********************@z14g2000cwz.googlegroups .com> from Julia
Briggs contained the following:

This obvisouly will work, until I start inputting birthdates pre-1970.
Is there something better (that is accurate) which will calculate &
accept the long birthdate format I am using here?


Look at the last entry here

http://www.liquidpulse.net/code/php/..._from_birthday

Not tested.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Julia Briggs wrote:
Hello, I am trying to find a workaround for the Unix date issue to
calculate ages based on a persons birthdate and the current date. Here
is the code I am working with now,

<?php

$dob = "10 July 1981";
$dob = strtotime($dob);

$today1 = strtotime ('now');
$today=date("d.m.Y",$today1);
$f_date1 = $person_dob;
$f_date=date("d.m.Y",$f_date1);

$difference = intval(((($f_date1 - $today1)/86400+1)*-1)/365);

print $difference;

?>

This obvisouly will work, until I start inputting birthdates pre-1970.
Is there something better (that is accurate) which will calculate &
accept the long birthdate format I am using here?


$dob = "21 Feb 1965";
$dob = strtotime($dob);
$difference = intval(abs($dob-time())/31536000);
echo $difference ."\n";
//Aho
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: PhillyFan | last post by:
I have a page setup using anchors. For some reason not all the anchors are working correctly. The last three anchors do not start where they are supposed to. I then started removing the anchor...
18
by: David Morris | last post by:
G'day. Is there a known "display:block;" problem in opera? In playing around trying to get some cross browser conformance, I either inadvertently or redundantly (depending on your perspective)...
0
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
6
by: ima | last post by:
http://www.kencoffman.com/templates.htm I've been experimenting with float:left and I've been able to clear those floats as far as Opera 8.02 and Firefox 1.0.6 but IE6 is a problem. I've...
9
by: rbronson1976 | last post by:
Hello all, I have a very strange situation -- I have a page that validates (using http://validator.w3.org/) as "XHTML 1.0 Strict" just fine. This page uses this DOCTYPE: <!DOCTYPE html PUBLIC...
4
by: Alan Silver | last post by:
Hello, If you add (say) two text boxes to a form, then add a validator with some simple rule for one of them, you can observer the following problem:- Type some erroneous value in the text...
7
by: Paul Watt | last post by:
Hi, at the bottom of my page, I have two different sentances in the same <div>. I've got the left hand sentance not positioned and it sits on the left hand side of the screen. The second sentance...
0
by: Gonza | last post by:
Hi group, i'm trying to add a customvalidator control to a custom web control. The problem is i'm getting a "Unable to find control id..." exception. Here is the code: public class CuitTextBox :...
1
by: swathichavalla | last post by:
Problem description: Clients working with an apple computer with the safari browser are experiencing problems with brokerage orders. When the client wants to enter a stock order, the order entry...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.