底下這段程式在不同php版本執行下有不同的結果。
<?php
$date1Str = '1988-04-18';
$date1 = new DateTime($date1Str,new DateTimeZone('PRC'));
$date2Str = '1900-01-31';
$date2 = new DateTime($date2Str,new DateTimeZone('PRC'));
echo "php version: ".phpversion();
echo "<br/>";
echo sprintf("%s與%s相差天數<br/>",$date1Str,$date2Str);
echo $date1->diff($date2)->days;
閱讀全文〈Datetime比對(diff)天數因PHP版本而不同〉