Quantcast
Channel: ASPRunner forums
Viewing all articles
Browse latest Browse all 2586

[SOLVED] Calculate Age

$
0
0
I'm a rank amateur PHP user here ... using latest PHPRunner 10.2 ... All I am trying to do is to simply display Age as calculated from a table's "BirthDate" field using a code snippet inserted into either or both the Add or Edit on design section, nothing complex whatsoever. This very simple code snippet I found is from a very nice 2014 Xlinesoft Blog article:

$time1 = new DateTime('1971-03-10');
$time2 = new DateTime('today');
echo $time2->diff($time1)->y;

Used as is as a code snippet in my project design section works great as is, resulting in 48 printed out nicely on either page as it should.

I have tried repeatedly to replace DateTime('1971-03-10'); with DateTime ($data["BD"]) or some such where BD is the date field from my table in this case the value from the field is: 1952-4-17 but that does not work. What am I missing here? (Probably a lot!). How do I get the value from the BD field into DateTime() correctly for DateTime() to recognize it correctly?

Randy J.

Viewing all articles
Browse latest Browse all 2586

Trending Articles