/ Published in: PHP
PHP script calculating the age of a customer coming from a webEdition field of the customer management.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!-- #################################################################### The code has to be placed between a <we:customer id="\$id"></we:customer> ##################################################################### --> <we:field type="date" name="Client_DateNaissance" format="d.m.Y" to="global" nameto="birthday" /> <?php $datetime1 = new DateTime($birthday); $datetime2 = new DateTime(); // creates the actual date $interval = $datetime1->diff($datetime2); $age = $interval->format('%y'); ?> <we:field type="date" name="Client_DateNaissance" format="d.m.Y" /> Ã <we:field type="print" name="Client_LieuNaissance" />. <we:ifVar type="global" name="age" match="18" operator="greater"><span style="color:green;">Il a <we:var type="global" name="age" /> ans.</span> <we:else /><span style="color:red; font-weight:bold;">Il a <we:var type="global" name="age" /> ans.</span></we:ifVar>