Posted By

steho on 12/08/12


Tagged

date webEdition wefield wecustomer weifVar weelse


Versions (?)

Calculates the age out of a webEdition date field of a customer


 / Published in: PHP
 

PHP script calculating the age of a customer coming from a webEdition field of the customer management.

  1. <!-- ####################################################################
  2. The code has to be placed between a <we:customer id="\$id"></we:customer>
  3. ##################################################################### -->
  4.  
  5. <we:field type="date" name="Client_DateNaissance" format="d.m.Y" to="global" nameto="birthday" />
  6.  
  7. <?php
  8. $datetime1 = new DateTime($birthday);
  9. $datetime2 = new DateTime(); // creates the actual date
  10. $interval = $datetime1->diff($datetime2);
  11. $age = $interval->format('%y');
  12. ?>
  13.  
  14. <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>

Report this snippet  

You need to login to post a comment.