<span class="m-l-10 text-success text-center pull-right" style="font-size:11px;">
<?
$time_diff=strtotime($row['plannedDate'])-time();
$minute=($time_diff/60);
$hour=($minute/60);
if($minute<=59){
$follow_time= round($minute). ' minutes left';
} elseif($hour <= 12){
$follow_time= round($hour,0). ' hour left';
}else{
$follow_time=date("Y-m-d",strtotime($row['plannedDate']));
}
echo $follow_time;
?>
</span>
在这里,我写了一些代码来显示剩余的分钟和小时。
但是,我只想显示会议剩余分钟的剩余分钟数,并且只有在时间结束时,我才想同时显示小时和分钟数。
例如,我分配了像2020-07-09 12:00:34这样的计划日期,它显示还剩28分钟,这是正确的,但如果计划日期时间超过了像还剩692分钟,我想同时显示小时和分钟。
如何制作?有人能帮我吗?
<span class="m-l-10 text-success text-center pull-right" style="font-size:11px;">
<?php
$time_diff=strtotime($row['plannedDate'])-time();
$minute=($time_diff/60);
$hour=($minute/60);
if($minute<=59 && $minute >0){
$follow_time= round($minute). ' minutes left';
} elseif($hour <= 12 && $hour > 0){
$follow_time= round($hour,0). ' hour left';
}else{
$hourOver = intdiv(abs($time_diff),3600);
$minuteOver = intdiv(abs($time_diff)%3600,60);
$minuteOver = str_pad($minuteOver, 2, "0", STR_PAD_LEFT);
$follow_time='started ' . $hourOver . ':' . $minuteOver . ' ago';
}
echo $follow_time;
?>
</span>