views:

16

answers:

1

Have a date of birth in format 'MM/dd/yy' for people born in the 1900's. I'm using Zend_Date to parse and convert the string value

$date = new Zend_Date();
$logger->info(sprintf('Convert DOB %s -> %s',$dateOfBirth,$date->toString('yyyy-M-dd')));

I get

2010-06-24T16:55:50+00:00 INFO (6): DOB 9/13/57
2010-06-24T16:55:50+00:00 INFO (6): Convert DOB : 9/13/57 -> 2057-9-13

I expected

2010-06-24T16:55:50+00:00 INFO (6): Convert 9/13/57 -> 1957-9-13

What am i missing? I don't think this is related to the real year 'yyyy' / ISO year 'YYYY' handling in Zend_Date.

My current horrible hack

$formattedDate = $date->toString('dd/M').'/19'.$date->toString('YY');
+1  A: 

short (1 or 2 digit) version of YEAR is always in current century. so use:

    $dob = '9/13/57';
    $date = new Zend_Date($dob, 'M/d/yy');
    echo $date->subYear(100)->toString('YYYY-MM-d');
SM