我正在获得转换为天数的随机数
CODE
$myDateValue = sql::readOne("SELECT `myDateValue` FROM table WHERE id = Value");
// the myDateValue is collected as TEXT in MYSQL
$futureDate =$myDateValue->myDateValue;
$now =time();
$futureDateTimestamp = strtotime($futureDate);
$days = number_format(($futureDateTimestamp - $now)/86400,2,'.',' ');
echo $days ;
这是随机数字 的 OUTPUTS
OUTPUT1: -14566.25566
OUTPUT2: 1452.33655
答案 0 :(得分:0)
其他一切都很好,只需添加此
即可 $diff = $futureDateTimestamp - $now;
$days = intval($diff /86400) ;
// to find the remaining hours
$rem_sec = $diff % 86400
$rem_hr = intval ($rem_sec/3600);
<p> You have total of <?php echo $days .'days and' $rem_hr ?> hours Left </p>