#native_company# #native_desc#
#native_cta#

Calculate dates before 1970, in forms etc–Defeat Windows limitations!

By R.McCain
on February 9, 2004

In form, designate 3 separate fields for your date. Mine were cdoby (i.e., ClientDateOfBirthYear), cdobm (ClientDateOfBirthMonth), and cdobd (ClientDateOfBirthDay). AGE (or other date calculations):

<?php // BIRTH YEAR NUMBER $yage = "$cdoby"; // $yage is a string $yage += 0; // $yage is now an integer--year of birth // BIRTH MONTH NUMBER $mage = "$cdobm"; // $mage is string $mage += 0; // $mage is now an integer--month of birth // BIRTH DAY NUMBER $dage = "$cdobd"; // $dage is string $dage += 0; // $dage is now an integer--day of birth //CALCULATE AGE //(including consideration for leap years) $leap = date("L"); //adds 0 if not leap year, +1 if it is $nowday = date("d"); //day part of today's date $nowday += 0; // convert date string to true integer $lnowday = ($nowday + $leap); //leapyear consideration $nowmonth =date("m"); //month part of today's date $nowmonth += 0; // convert date string to true integer $myyear = date("Y"); //this year as 4 digit number $age = ($myyear-$yage); //Almost there! ?> //DETERMINE IF BIRTHDAY HAS TAKEN PLACE OR NOT //AND PRINT AGE <?php if (($nowmonth < $mage) OR (($nowmonth < $mage) AND ($lnowday < $dage))) { $age=$age-1; } print $age ?>

It works great--however, I've only tested it back to the year 1949.

You folks have helped me so much--I hope this benefits someone as well!