我有如下代码:
<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 ?>">
问题:
<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 ?>">
我现在想得到日期和日期之间的人的年龄 ex: 12years
,但我不知道该怎么做。