I have the code as below:
<tr>
<td>Date :</td>
<td><input type="text" name="txtdembauche" value="<?php echo $value['dateEmbouche'] ?>"class="validate[required] text-input datepicker TextInput" id="txtdembauche"/></td>
<td></td>
</tr>
<?php
@$date1 = $_POST['txtdembauche'];
$date2 = date("Y-m-d");
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
?>
<tr>
<td>Ancienneté : <b id="anciente" style="color:#FF0000;"><?php printf("%d years, %d months, %d days\n <br />", $years, $months, $days); ?></b></td>
<td></td>
<td></td>
</tr>
<input type="text" name="dateResult" id="dateResult" value="<?php // I do not know how to calculate this ?>">
Problem:
<tr>
<td>Ancienneté : <b id="anciente" style="color:#FF0000;"><?php printf("%d years, %d months, %d days\n <br />", $years, $months, $days); ?></b></td>
<td></td>
<td></td>
</tr>
It not works well,it display the wrong date.
<input type="text" name="dateResult" id="dateResult" value="<?php // I do not know how to calculate this ?>">
I want to get the age of person between date and date now ex: 12years, but I do not know how to do this.
As for comments this is something about your coding technique or the concept. I have created a test code just follow it and identify where you went wrong