0

is there any way to check how old customer in terms of registration like one year old customer like that or we have to write code for the same

$d1 = new DateTime(date('Y-m-d',Mage::getModel('customer/customer')->load(4)->getCreatedAtTimestamp()));
$d2 = new DateTime();
echo $yeardifference = $d2->diff($d1);

but i give blank value

1 Answer 1

1

Your code is fine, please make these changes it should return your result

$yeardifference = $d1->diff($d2); 
echo $yeardifference->format('%a days');

This will return the difference in days. You can use other formats available on your php manual. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.